Excel Office Web Components (OWC11) and ASP.NET

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

then program:

        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.
Who is Participating?
mAjKoLConnect With a Mentor Commented:
Why are you exporting it to HTML?


I am assuming that you are confident that your users have excel on their machines, so why not simply save it as xls ??

I'll have to look up OWC11 because I am used to simply using the office application objects directly.

mAjKoLConnect With a Mentor Commented:
Here is an article about creating Excel Spreadsheets using OWC
Charting with Office Web Components:
Using the Office Web Components to create dynamic charts
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

grostonAuthor Commented:
I accepted the answer just to close this question.

The references pointed to by mAjKoL are for ASP, not ASP.NET. They are also focused on OWC10 and charting, not spreadsheet.

The webcast is also only maginally useful.

Bottom line: OWC might be useful, but the almost complete lack of documentation makes it worthless. You are better off installing Excel and using Excel objects. Those methods are documented and the funtion properly.
I too need to be able to display an excell file to our intranet users and allow then to use an excel spreadsheet (stored on server) to calculate loan amounts.

i have worked out that if i add a spreadsheet using OWC then i can then set the data source and get the information on the sheet.

Problem is this sheet has NO formatting and none of the macro's or formulea seems to be working.

Any ideas please?
Hi...do you solve the problem eventually? Could you please email your complete solutions because I am facing the same problems as well. Thanks in advance.

My email is yeesoon.yeo@gmail.com
grostonAuthor Commented:
EE frowns upon such requests.
My solution was to use plain-old Excel - at the University, we have a site license, so it is feasible. Also, the site is restricted to the University so there are no licensing issues.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.