"Fossies" - the Fresh Open Source Software Archive

Member "php_writeexcel-0.3.0/example-simple.php" (1 Nov 2005, 1061 Bytes) of package /linux/www/old/php_writeexcel-0.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "example-simple.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 set_time_limit(10);
    4 
    5 require_once "class.writeexcel_workbook.inc.php";
    6 require_once "class.writeexcel_worksheet.inc.php";
    7 
    8 $fname = tempnam("/tmp", "simple.xls");
    9 $workbook = &new writeexcel_workbook($fname);
   10 $worksheet = &$workbook->addworksheet();
   11 
   12 # The general syntax is write($row, $column, $token). Note that row and
   13 # column are zero indexed
   14 #
   15 
   16 # Write some text
   17 $worksheet->write(0, 0,  "Hi Excel!");
   18 
   19 # Write some numbers
   20 $worksheet->write(2, 0,  3);          # Writes 3
   21 $worksheet->write(3, 0,  3.00000);    # Writes 3
   22 $worksheet->write(4, 0,  3.00001);    # Writes 3.00001
   23 $worksheet->write(5, 0,  3.14159);    # TeX revision no.?
   24 
   25 # Write two formulas
   26 $worksheet->write(7, 0,  '=A3 + A6');
   27 $worksheet->write(8, 0,  '=IF(A5>3,"Yes", "No")');
   28 
   29 # Write a hyperlink
   30 $worksheet->write(10, 0, 'http://www.php.net/');
   31 
   32 $workbook->close();
   33 
   34 header("Content-Type: application/x-msexcel; name=\"example-simple.xls\"");
   35 header("Content-Disposition: inline; filename=\"example-simple.xls\"");
   36 $fh=fopen($fname, "rb");
   37 fpassthru($fh);
   38 unlink($fname);
   39 
   40 ?>