ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

Script Output:

Click here to view an HTML table within Excel.

You'll need to have Excel installed for it to work. To save a copy simply right-click the link above and select "Save Target As..."


ASP.NET Version

Depending on what your web site offers, it can often be helpful to your visitors if you offer your content in formats other then HTML. One of the more popular formats for sites that deal with numerical data, stocks, money, etc. is that of a Microsoft Excel spreadsheet. Excel is a pretty widely used spreadsheet program and there's even a free viewer available for users that don't have Excel installed.

There are a few different ways to deal with Excel from an ASP page.

The first is to use Excel as an ADO data source (which we cover in our Excel Data sample). This offers a great deal of functionality, but can be a real pain and does not scale very well since Excel was not originally designed to be used in this manner.

You can also use the Excel objects from your ASP scripts on the server (ie. objSheet = CreateObject("Excel.Sheet")) and manipulate an Excel document that way, but that requires Excel be installed on the server and scales even more poorly then using Excel as a data source.

Excel 2000 and later include the Office Web Components interface which is much better in terms of usability and scalability. If you use this approach, be sure to use OWC.Spreadsheet and not Excel.whatever. For more info on this check out Creating Excel Spreadsheets with Office Web Components over at 4GuysFromRolla.)

The option this sample illustrates is much simpler than the two listed above. Unfortunately, this simplicity is a double-edged sword. While this option is extremely easy to implement and scales gracefully, you are somewhat limited in terms of functionality. It works great for transfering basic data (from any data source you want) into an Excel sheet, but anything beyond basic formulas can become quite troublesome. But... if this option will do everything you want, it's probably the best way to go.

While I'm on the topic of Excel... those of you who need to do more complex things then this solution allows might want to check out some of the third party components available for working with Excel from ASP. There are probably a lot more, but these are the ones that come to mind:


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers