Forum Moderators: coopster

Message Too Old, No Replies

export to excel

         

jackvull

11:17 am on Nov 26, 2007 (gmt 0)

10+ Year Member



I have the following code, which exports a table to an Excel file.
WHat I would like to do is export it to the local server instead, then close the Excel file, which should make it runa macro to tidy up the data.
Any ideas on how to save it locally instead of outputting the excel file to the user?


<?php

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=Structure.xls");
header("Content-Transfer-Encoding: BINARY");
include "db.php";
?>
<table>
<tr>
<td>Cost Centre</td>
<td>Company Code</td>
<td>Company Description</td>
<td>Profit Centre Description</td>
<td>Profit Centre Manager</td>
<td>PCMEmailAddress</td>
<td>DFD</td>
<td>DFDEmailAddress</td>
<td>Business Unit</td>
<td>Div Level</td>
<td>Div Level Description</td>
<td>Bus Unit Level</td>
<td>Regional Level</td>
</tr>
<?
$url2 = "select * from structure";
$resulturl2 = mssql_query($url2);
while ($resurl2=mssql_fetch_assoc($resulturl2))
{
?>
<tr>
<td><? echo $resurl2['Cost Centre'];?> </td>
<td><? echo $resurl2['Company Code'];?> </td>
<td><? echo $resurl2['Company Description'];?> </td>
<td><? echo $resurl2['Profit Centre Description'];?> </td>
<td><? echo $resurl2['Profit Centre Manager'];?> </td>
<td><? echo $resurl2['PCMEmailAddress'];?> </td>
<td><? echo $resurl2['DFD'];?> </td>
<td><? echo $resurl2['DFDEmailAddress'];?> </td>
<td><? echo $resurl2['Business Unit'];?> </td>
<td><? echo $resurl2['Div Level'];?> </td>
<td><? echo $resurl2['Div Level Description'];?> </td>
<td><? echo $resurl2['Bus Unit Level'];?> </td>
<td><? echo $resurl2['Regional Level'];?> </td>
</tr>
<?
}

?>

eelixduppy

7:09 pm on Nov 28, 2007 (gmt 0)



There are classes available online for Excel file manipulation and creation. Perhaps you want to take a look at a few [google.com].