Click here to Skip to main content
15,885,537 members
Articles / Web Development / HTML

Adding Persistent Excel Sheets to Your Web Page

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
13 Apr 2011CPOL 10.3K   2  
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:

HTML
<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 here.

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:

JavaScript
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)


Written By
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 --