Spider Web Woman Designs

Displaying FrontPage Database Results as an Excel Spreadsheet

Introduction

The FrontPage 2000 Database Results Wizard (DRW) allows you to query information in a database and display it as an HTML table. You can also display the information as an Excel spreadsheet within the user's browser (if the user is running Internet Explorer and has MS Excel installed on their machine). The user can analyze the DRW results with Excel and save the results as an Excel spreadsheet.

Technique

Displaying DRW results as an Excel spreadsheet requires that the content type of the ASP page be set to "application/vnd.ms-excel" and ONLY the table html be sent to the browser, ie, no <html> tags, etc. (This may also require IIS5 since it automatically strips the DRW code from the output, leaving only the table html.)

You use the Response Object to set the content type and assure that only the <table> is sent to the browser. This is done by adding 4 inline ASP scripts to the DRW page that;

  1. buffer the html - Response.Buffer = True
  2. clear the html just prior to the <table> tag - Response.Clear
  3. set the content type to excel - Response.ContentType = "application/vnd.ms-excel" and 
  4. end the html immediately after the </table> tag - Response.End.

Implementation

Here's how to implement this technique;

  1. Add the DRW to the page, specifying a table as the format for the results.
     
    (If you want to use a form to query the database, create a separate form page that submits to the DRW page.)
     
  2. In HTML mode, add the ASP scripts (in maroon) to the existing html (in blue) as illustrated below.
     
    <%Response.Buffer = True%>
    <html>
    ...
    <body>

    <%Response.Clear%>
    <%Response.ContentType = "application/vnd.ms-excel"%>

    <table width=
    "100%" border="1">
    ...
    </table>

    <%Response.End%>

    </body>
    ...
     
  3. Access the page from the server.

© Copyright 2002 Stephen C. Travis, all rights reserved. Republished with the permission of the author.

Back to Stephen Travis' Thingumajig