Convert HTML Table into Spreadsheet File
May 12th, 2008 | posted by Anonymous
in
You have already create html report in table format. if you want to convert the html table into spreadsheet file, Microsoft Office Excel or OpenOffice.org Spreadsheet, please check this tips.
spreadsheet.php <?php if ($_GET['mode']=='xls') { header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=spreadsheet.xls"); } elseif ($_GET['mode']=='ods') { header("Content-type: application/vnd.oasis.opendocument.spreadsheet"); header("Content-Disposition: attachment; filename=spreadsheet.ods"); } header("Pragma: no-cache"); header("Expires: 0"); ?> <table border="1"> <tr bgcolor="#DEDEDE"><td><strong><font face="Arial">City</font></strong></td> <td><strong><font face="Arial">Country</font></strong></td> <td><strong><font face="Arial">Population</font></strong></td> </tr> <tr> <td>Tokyo</td><td>Japan</td><td>28025000</td></tr> <tr> <td>Mexico City</td><td>Mexico</td><td>18131000</td></tr> <tr> <td>Mumbai</td><td>India</td><td>18042000</td></tr> <tr> <td>Sao Paulo</td><td>Brazil</td><td>17711000</td></tr> <tr> <td>New York City</td><td>USA</td><td>16626000</td></tr> </table>
Usage :
<a href="spreadsheet.php?mode=xls" target="_blank">Open as Microsoft Office Excel</a> <a href="spreadsheet.php?mode=ods" target="_blank">Open as OpenOffice.org Spreadsheet</a>
Examples :
Open as Microsoft Office Excel
Open as OpenOffice.org Spreadsheet











Post new comment