Click here to Skip to main content
Click here to Skip to main content

Adding persistent Excel sheets to your web page

, 13 Apr 2011
Rate this:
Please Sign up or sign in to vote.
How to add a persistent Excel sheet to your web page.

Adding an Excel sheet to your web page can be done by simply adding an object with a particular classid to your page, as shown below:

<table > 
<tr style="height: 500px">
<td>
<object id="spreadsheet1" width="100%" height="100%" 
   classid="clsid:0002E559-0000-0000-C000-000000000046" viewastext>
<param name="MaxHeight" value="1000px" />
<param name="MaxWidth" value="1000px" />
</object>
</td>
</tr>
</table>

This will only work on Internet Explorer, and you also need to have OWC (Office Web Component) installed on your computer. If you have Microsoft Office 2003 installed, you would already have OWC; otherwise, you can download it from: http://www.microsoft.com/downloads/en/details.aspx?FamilyId=7287252C-402E-4F72-97A5-E0FD290D4B76&displaylang=en.

To make the Excel sheet persistent, you want access to its data so you can store it to the database. The object shown above is not an ASPX control that you can have access to in code-behind. The JavaScript code in your page, however, would have access to this data as:

document.form1.spreadsheet1.XMLData

You can use a Web Service to store or retrieve data. To access a Web Service from JavaScript, you have two options. One is using the webservice.htc component to bring Web Service behaviour to your web page as explained in About WebService Behavior. The other option is to use ASP.NET AJAX to access Web Services as outlined in Calling Web Services with ASP.NET AJAX.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Morris Bahrami
Architect
Australia Australia
I have over 17 years of experience in software development in a variety of fields. For last 7 years the emphasis has been mostly on .NET technology (C# and VB.NET) which includes WPF, WCF and ASP.NET AJAX. Also have SQL Server experience including SSIS and SSRS. My blog (http://morrisbahrami.blogspot.com) has a collection of tips and general info for Microsoft Developers.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 13 Apr 2011
Article Copyright 2011 by Morris Bahrami
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid