If you are interested, I created a library which produces native format (ie: binary) Excel spreadsheets (XLS) in PHP4. The same library can also support createion of Lotus Spreadsheets (WK1), HTML webpages (HTM), Comma Separated Values (CSV), Database files (DBF), WordPerfect Merge Files (WP5), and (soon) XML documents (XML).
Let me know if this is what you are looking for.
-- Michael
Darkstreak Consulting
www.darkstreak.com
Usage example:
<?php
require_once("deliveryfmt_functions.php"); # Load the library
deliveryfmt_initialize(); # Initialize the library
deliveryfmt_set_format('xls', false); # Select Excel (.xls) formatting
header('Content-type: '.deliveryfmt_mimetype()); # MIME-type
header('Content-disposition: attachment;filename="results.'.deliveryfmt_format_extension().'"'); # Try to name the output file
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); # Date in the past
header('Last-Modified: '.gmdate("D, d M Y H:i:s").' GMT'); # always modified
$nocache = 'Cache-Control: no-cache, must-revalidate'; # HTTP/1.1
if ($SERVER_PROTOCOL == 'HTTP/1.0') { $nocache = 'Pragma: no-cache'; } # HTTP/1.0
header($nocache);
header('Content-Transfer-Encoding: binary'); # Binary data
deliveryfmt_header(); # Set up Excel file header
Two different ways of using the functions. One way is to set the column names,
then just pass in array rows of data:
$colnames = array(1=>'banana', 2=>'apple', 3=>'pear');
deliveryfmt_set_column_names($colnames);
$data = array('banana'=>'whatever', 'apple'=>'you', 'pear'=>'like');
deliveryfmt_put_array($data);
$data = array('banana'=>'foo', 'apple'=>'3.14159265', 'pear'=>'2');
deliveryfmt_put_array($data);
$data = array('banana'=>'bar', 'apple'=>'Mac', 'pear'=>'Bartlet');
deliveryfmt_put_array($data);
The second way is to create a two dimensional array and have the library
do most of the work:
$data = array('first'=>array('banana'=>'whatever', 'apple'=>'you', 'pear'=>'like'),
'second'=>array('banana'=>'foo', 'apple'=>'3.14159265', 'pear'=>'2'),
'third'=>array('banana'=>'bar', 'apple'=>'Mac', 'pear'=>'Bartlet'));
deliveryfmt_put_2d_array($data);
deliveryfmt_trailer(); # Add Excel file trailer
$buffer = deliveryfmt_finish(); # Finish up the Excel file and return the contents
echo $buffer; # Send it to the waiting browser
?>