A simple way of exporting data to the web in excel format, you don’t have to create an excel file, you just have to define the proper headers for the browser.
First define a filename, and headers.
$filename = "test.xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
Now just send the clear text data you want the excel file to contain, use “\n” and “\t” for row and column navigation.
For example:
echo "column1 \t column2\n";
echo "row1 value1" . "\t" . "row1 value2\n";
echo "row2 value1" . "\t" . "row2 value2";
exit(); //remember to stop output unless you do it its own file.
Click the link below to see how the export of this data would look like.
http://thronic.com/pubfiles/export_excel_example.php
courtesy: Dag J. Nedrelid
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment