Excel Office Web Components (OWC11) and ASP.NET
Posted on 2004-04-28
I am having a tough time getting started using OWC. Maybe because MS didn't provide any documentation...
I have found out how to dynamically create a spreadsheet:
Add a reference to OWC11
Dim xlsheet As New SpreadsheetClass
' put some data into the spreadsheet.
Dim i As Int32
For i = 1 To 10
xlsheet.ActiveSheet.Cells(i, i) = i.ToString
' use this just to get a unique filename...
Dim xlFileName As String = System.DateTime.Now.Ticks.ToString() + ".xls"
' save it off to the filesystem...
xlsheet.Export(Server.MapPath(".") + "\\" + xlFileName, OWC11.SheetExportActionEnum.ssExportActionNone, OWC11.SheetExportFormat.ssExportHTML)
' set content header so browser knows you'r sending Excel workbook...
Response.ContentType = "application/x-msexcel"
' stream it on out!
Response.WriteFile(Server.MapPath(".") + "\\" + xlFileName)
This isn't quite what I need.
What I would like to do is to
1) "open" a base spreadsheet (has fomatting, borders, etc)
2) populate the spreadsheet with data from SQL (the easy part)
3) present the data to the user
4) provide a button so the user can save the data to a local file
optional) provide the means for the user to edit the data in the spreadsheet prior to saving it.
To accomplish step 1, I believe that the spreadsheet needs to be saved as XML (read this somewhere). I have done this. But now what?
If you do not have the specific answer to this question, but can point me to a good OWC11 reference that uses .NET technology, that may well be accepted as a valid answer.