PHPExcel_Writer_Excel5_Writer
[ class tree: PHPExcel_Writer_Excel5_Writer ] [ index: PHPExcel_Writer_Excel5_Writer ] [ all elements ]

Source for file Writer.php

Documentation is available at Writer.php

  1. <?php
  2. /*
  3. *  Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
  4. *
  5. *  PERL Spreadsheet::WriteExcel module.
  6. *
  7. *  The author of the Spreadsheet::WriteExcel module is John McNamara
  8. *  <jmcnamara@cpan.org>
  9. *
  10. *  I _DO_ maintain this code, and John McNamara has nothing to do with the
  11. *  porting of this code to PHP.  Any questions directly related to this
  12. *  class library should be directed to me.
  13. *
  14. *  License Information:
  15. *
  16. *    PHPExcel_Writer_Excel5_Writer:  A library for generating Excel Spreadsheets
  17. *    Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
  18. *
  19. *    This library is free software; you can redistribute it and/or
  20. *    modify it under the terms of the GNU Lesser General Public
  21. *    License as published by the Free Software Foundation; either
  22. *    version 2.1 of the License, or (at your option) any later version.
  23. *
  24. *    This library is distributed in the hope that it will be useful,
  25. *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  27. *    Lesser General Public License for more details.
  28. *
  29. *    You should have received a copy of the GNU Lesser General Public
  30. *    License along with this library; if not, write to the Free Software
  31. *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  32. */
  33.  
  34. require_once 'PHPExcel/Writer/Excel5/Workbook.php';
  35.  
  36. /**
  37. * Class for writing Excel Spreadsheets. This class should change COMPLETELY.
  38. *
  39. @author   Xavier Noguer <xnoguer@rezebra.com>
  40. @category FileFormats
  41. @package  PHPExcel_Writer_Excel5_Writer
  42. */
  43.  
  44. {
  45.     /**
  46.     * The constructor. It just creates a Workbook
  47.     *
  48.     * @param string $filename The optional filename for the Workbook.
  49.     * @return PHPExcel_Writer_Excel5_Workbook The Workbook created
  50.     */
  51.     function PHPExcel_Writer_Excel5_Writer($filename '')
  52.     {
  53.         $this->_filename = $filename;
  54.         $this->PHPExcel_Writer_Excel5_Workbook($filename);
  55.     }
  56.  
  57.     /**
  58.     * Send HTTP headers for the Excel file.
  59.     *
  60.     * @param string $filename The filename to use for HTTP headers
  61.     * @access public
  62.     */
  63.     function send($filename)
  64.     {
  65.         header("Content-type: application/vnd.ms-excel");
  66.         header("Content-Disposition: attachment; filename=\"$filename\"");
  67.         header("Expires: 0");
  68.         header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
  69.         header("Pragma: public");
  70.     }
  71.  
  72.     /**
  73.     * Utility function for writing formulas
  74.     * Converts a cell's coordinates to the A1 format.
  75.     *
  76.     * @access public
  77.     * @static
  78.     * @param integer $row Row for the cell to convert (0-indexed).
  79.     * @param integer $col Column for the cell to convert (0-indexed).
  80.     * @return string The cell identifier in A1 format
  81.     */
  82.     function rowcolToCell($row$col)
  83.     {
  84.         if ($col 255//maximum column value exceeded
  85.             throw new Exception("Maximum column value exceeded: $col");
  86.         }
  87.  
  88.         $int = (int)($col 26);
  89.         $frac $col 26;
  90.         $chr1 '';
  91.  
  92.         if ($int 0{
  93.             $chr1 chr(ord('A'$int 1);
  94.         }
  95.  
  96.         $chr2 chr(ord('A'$frac);
  97.         ++$row;
  98.  
  99.         return $chr1 $chr2 $row;
  100.     }
  101. }

Documentation generated on Mon, 27 Oct 2008 08:42:15 +0100 by phpDocumentor 1.4.1