Location: PHPKode > scripts > phpMyAccess > phpmyaccess-1.5.3/phpmyaccess/xlsgen.php
<?php
 // totally stolen, messed up and adapted for this limited use.
 // original author Erol Ozcan (eozcan AT superonline.com)
 // psxlsgen class on phpclasses.upperdesign.com
 // free registration required to download there.

 $xls['xls_data'] = "";      // where generated xls be stored
 $xls['crow']     = 0;         // current row number
 $xls['ccol']     = 0;         // current column number
 $xls['totalcol'] = 0;         // total number of columns
 $xls['errno']    = 0;         // 0=no error
 $xls['error']    = "";        // error string

 // Default constructor
 function  xlsStart() {
   // begin of the excel file header
   $GLOBALS['xls']['xls_data'] = pack( "ssssss", 0x809, 0x08, 0x00,0x10, 0x0, 0x0 );
 }

 // end of the excel file
 function xlsEnd() {
   $GLOBALS['xls']['xls_data'] .= pack( "ss", 0x0A, 0x00 );
   return;
 }

 // write a Number (double) into row, col
 function xlsWriteNumber_pos( $row, $col, $value ) {
   $GLOBALS['xls']['xls_data'] .= pack( "sssss", 0x0203, 14, $row, $col, 0x00 );
   $GLOBALS['xls']['xls_data'] .= pack( "d", $value );
   return;
 }

 // write a label (text) into Row, Col
 function xlsWriteText_pos( $row, $col, $value ) {
   $len = strlen( $value );
   $GLOBALS['xls']['xls_data'] .= pack( "s*", 0x0204, 8 + $len, $row, $col, 0x00, $len );
   $GLOBALS['xls']['xls_data'] .= $value;
   return;
 }

 // insert a number, increment row,col automatically
 function xlsInsertNumber( $value ) {
   xlsWriteNumber_pos( $GLOBALS['xls']['crow'], $GLOBALS['xls']['ccol'], &$value );
   $GLOBALS['xls']['ccol']++;
   return;
 }

 // insert a number, increment row,col automatically
 function xlsInsertText( $value ) {
   xlsWriteText_pos( $GLOBALS['xls']['crow'], $GLOBALS['xls']['ccol'], &$value );
   $GLOBALS['xls']['ccol']++;
   return;
 }

 // Change position of row,col
 function xlsChangePos( $newrow, $newcol ) {
    $GLOBALS['xls']['crow'] = $newrow;
    $GLOBALS['xls']['ccol'] = $newcol;
    return;
 }

 // new line (first column, next row)
 function xlsNewLine() {
    $GLOBALS['xls']['ccol'] = 0;
    $GLOBALS['xls']['crow']++;
    return;
 }

 // send generated xls as stream file
 function xlsSendFile() {
    xlsEnd();
    header ( "Expires: Mon, 1 Apr 1974 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=report.xls" );
    header ( "Content-Description: PHP Generated XLS Data" );
    print $GLOBALS['xls']['xls_data'];
 }

 function GetXls() {
        xlsSendFile();
 }

?>
Return current item: phpMyAccess