Spreadsheet_Excel_Writer

The pear package Spreadsheet_Excel_Writer rocks. I include a file similar to excel.inc file in my scripts, and then send data as needed to the spreadshhet.

Assume the data is organized in an array $data like this:
$data = array(0=>array("f0"=>"v00", "f1"=>"v01",..."fn"=>"v0n"),
1=>array("f0"=>"v10", "f1"=>"v11",..."fn"=>"v1n"),
.....
n=>array("f0"=>"vn0", "f1"=>"vn1",..."fn"=>"vnn")
);

and we are interested in the fields f0, f1, f2 only. The headers for these fields should be “Field One”, “Field Two”, “Field Three”. This is easily achieved by this snippet:




simple_header(array("Field One", "Field Two", "Field Three"));
$lookat = array("f0","f1","f2");
for($j=0; $j

And don't forget a $xls->close(); after all the data has been output!

Leave a Comment

You must be logged in to post a comment.