We are going to create a simple calculator with Sum, Difference, Division and Multiplication operations using Excel 2007.

Open a new workbook.
Excel1.jpg

Under column
A1 – Type ‘Value 1’
A2 – Type ‘Value 2’
A3 – Type ‘Sum’
A4 – Type ‘Diff’
A5 – Type ‘Div’
A6 – Type ‘Mul’

Specify the formula under the column
B3 – Type ‘=B1+B2’
B4 – Type ‘=B1-B2’
B5 – Type ‘=B1/B2’
B6 – Type ‘=B1*B2’
Now when we give numeric values to column B1 and B2, we will get the results of operation as bellow:
Excel2.jpg

Now that we have a simple calculator ready to use.

Now lets build an application to assign values to B1 and B2 and get the result using Excel Services – MOSS 2007 and .Net.

Initial Setup:
1. Under your MOSS 2007 site, create a document library and name it ExcelService.
2. Upload the excel file that we created and save it as mytest.xlsx

We now have access to the webservice provided by MOSS 2007, to access the workbook that we have uploaded.
The url to this would look like:
http://MOSS Server/SiteDirectory/your site/vtibin/ExcelService.asmx

Configure the web application:
1. Open the web.config file
2. Change the following under <appSettings>
<appSettings>
<add key="MyService.ExcelService" value="http://[MOSS Server]/SiteDirectory/[your site]/_vti_bin/ExcelService.asmx"/>
<add key="WorkBookPath" value="http://[MOSS Server]/SiteDirectory/[your site]/ExcelServices/mytest.xlsx"/>
    <add key="UICultureName" value="en-US"/>
    <add key="DataCultureName" value="en-US"/>
    <add key="WorkSheetName" value="Sheet1"/>
    <add key="WorkSheetInputCellValue1" value="B1"/>
    <add key="WorkSheetInputCellValue2" value="B2"/>
    <add key="WorkSheetOutputCellAdd" value="B3"/>
    <add key="WorkSheetOutputCellSub" value="B4"/>
    <add key="WorkSheetOutputCellDiv" value="B5"/>
    <add key="WorkSheetOutputCellMul" value="B6"/>
</appSettings>


You are now ready to work with your web application to use the MOSS 2007 Excel Services.
The web calculator will look as bellow:
calc.jpg

Moss_Excel_Services.doc

---------------------------------------------------------------------------------------

Last edited May 6, 2010 at 10:58 AM by sivakesh, version 4