<?php // ----- begin of function library ----- // excel begin of file header function xlsbof() { echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); return; } // excel end of file footer function xlseof() { echo pack("ss", 0x0a, 0x00); return; } // function to write a number (double) into row, col function xlswritenumber($row, $col, $value) { echo pack("sssss", 0x203, 14, $row, $col, 0x0); echo pack("d", $value); return; } // function to write a label (text) into row, col function xlswritelabel($row, $col, $value ) { $l = strlen($value); echo pack("ssssss", 0x204, 8 + $l, $row, $col, 0x0, $l); echo $value; return; } // ----- end of function library ----- ?>
// // to display the contents directly in a mime compatible browser // add the following lines on top of your php file:
<?php header ("expires: mon, 26 jul 1997 05:00:00 gmt"); header ("last-modified: " . gmdate("d,d m yh:i:s") . " gmt"); header ("cache-control: no-cache, must-revalidate"); header ("pragma: no-cache"); header ('content-type: application/x-msexcel'); header ("content-disposition: attachment; filename=empllist.xls" ); header ("content-description: php/interbase generated data" ); // // the next lines demonstrate the generation of the excel stream // xlsbof(); // begin excel stream xlswritelabel(0,0,"this is a label"); // write a label in a1, use for dates too xlswritenumber(0,1,9999); // write a number b1 xlseof(); // close the stream ?>