Thursday, March 29, 2012

office web component

to everyone,in asp.net,how can i use the office web componentHi,

I found this article very helpful

http://www.devx.com/xml/Article/7018/0
Hello,

you have different options to use the OWC but basically you have to store all the files which you want to display with owc in XML-format. For example if you want to load an excel-spreadsheet you must save this as an "XML-Spreadsheet" file before. This is the only format that the OWC Spreadsheet Component can read and bring in all the formulas, etc. Do not attempt to load a regular XLS file in OWC, it can't be done...

Then you can load the spreadsheet in your webform with simple code like i show you in the following example. This is VB.Net but of course you can do it in C# as well:

Dim spreadsheet As OWC10.SpreadsheetClass = New SpreadsheetClass
spreadsheet .XMLURL = MapPath("OWCTest.xml")
spreadsheet .Range("B1:B3").Cells(1).Value = Convert.ToInt32(txtField1.Text)
spreadsheet .Range("B1:B3").Cells(2).Value = Convert.ToInt32(txtField2.Text)
spreadsheet .CalculateFull()
lblMessage.Text = "The result is: " & (sp.Range("B1:B3").Cells(4).Value)
This is an absolute beginner example. If you want to learn more i would recommend the following links:

Creating Excel Spreadsheets with Office Web Components (OWC)
Charting with Office Web Components (OWC)
Creating Dynamic Charts in ASP. NET Web Applications Using OWC

Even MS has a good KB article about this issue:
HOW TO: Use a DataSet with the Office XP Chart Component and ASP.NET

HTH,

0 comments:

Post a Comment