Results 1 to 6 of 6

Thread: Excel

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    29

    Excel

    Hi,

    I have created an HTML report. Very basic - all it does is read thru
    a table in the database and for each record read, it displays it on the page. I now want to give the user the facility to be able to save this report in Excel. IE. click on a button and then save it to .xls OR it can be displayed in Excel immediately - without the user clicking a button.

    I have heard that you just need to put some or other tag in the
    meta tag!!??

    Any ideas?

    Thx, L

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You can write a .csv file to the server and redirect to it. If the user has Excel installed, it will open inside of IE..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    As the very first line on your page, try this
    Code:
    <%
     Response.ContentType = "application/vnd.ms-excel"
    %>
    I use this type of thing a lot to provide a option of the report going to an HTML page, or a Word document (I have a check box, which if checked, sends the output to Word). It should work the same for Excel although I've not tried Excel yet.

  4. #4
    Hyperactive Member Radames's Avatar
    Join Date
    Feb 2001
    Location
    Tech Tropics
    Posts
    360
    Hey Hack can you tell me a site with a tutorial on that? Or what book you use? Thanx
    Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    29
    Thank you Hack.

    I got it going, but do you know how I can specify the columns in which the data must be written.

    I read 3 variables from my table and want to write each field in a different column.

    IE. Names in Column B, Surnames in Column D and Phone in Column F.

    You know what I mean??

  6. #6
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    Here's an example of a small, but complete ASP-page. It's stunningly simple

    Code:
    <%@ Language="VBScript" %>
    <%
        Response.Buffer = True
        Response.ContentType = "application/vnd.ms-excel"
    %>
    <table border="1">
    <tr>
        <th>Column A</th>
        <th>Column B</th>
        <th>Totals Column</th>
    </tr>
    <tr>
        <td>4</td>
        <td>3</td>
        <td><font color="red">=sum(a2:b2)</font></td>
    </tr>
    <tr>
        <td>2</td>
        <td>1</td>
        <td><font color="red">=sum(a3:b3)</font></td>
    </tr>
    </table>
    Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width