Yes, yes and yes !

Somebody posted this question a couple of weeks ago and out of curiosity I tried it - works fine for basic tables importing as HTML, I guess if I get my hands on the XLS -> XML output format I'll try that too. Heres some example code for you to try :

<?php
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=test.xls");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
        <title>Output HTML table in Excel format from PHP</title>
</head>
<body>
<table border="1">
        <tr>
                <th>Header 1</th>
                <th>Column 2</th>
                <th>3rd column</th>
        </tr>
        <tr>
                <td>item 1</td>
                <td>property 1</td>
                <td>method 1</td>
        </tr>
        <tr>
                <td>item 2</td>
                <td>property 2</td>
                <td>method 2</td>
        </tr>
        <tr>
                <td>27.5015</td>
                <td>42.5151</td>
                <td>7053</td>
        </tr>
</table>

</body>
</html>

All you need to work out is how to send MySQL output as a table (;-o) and remember to send the headers as above.

HTH
Neil Smith.

At 05:26 02/04/2003 +0000, you wrote:

>
From: "Chris and Trish Kaelin" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Date: Tue, 01 Apr 2003 16:58:20 -0500
Mime-Version: 1.0
Content-Type: text/plain; format=flowed
Message-ID: <[EMAIL PROTECTED]>
Subject: Output to Excel File

At my job, we are using ColdFusion with an Oracle database, and one the things we do is output data in a HTML table using contentType = "application/msexcel", which creates a MS Excel spreadsheet.

The two web sites I am running from home are PHP with an mySQL database. Is there a similar method in PHP ot create a MS Excel spreadsheet?

Chris Kaelin


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to