Spreadsheet_Excel_Writer
[ class tree: Spreadsheet_Excel_Writer ] [ index: Spreadsheet_Excel_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. *    Spreadsheet_Excel_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 'PEAR.php';
  35. require_once 'Spreadsheet/Excel/Writer/Workbook.php';
  36.  
  37. /**
  38. * Class for writing Excel Spreadsheets. This class should change COMPLETELY.
  39. *
  40. @author   Xavier Noguer <xnoguer@rezebra.com>
  41. @category FileFormats
  42. @package  Spreadsheet_Excel_Writer
  43. */
  44.  
  45. {
  46.     /**
  47.     * The constructor. It just creates a Workbook
  48.     *
  49.     * @param string $filename The optional filename for the Workbook.
  50.     * @return Spreadsheet_Excel_Writer_Workbook The Workbook created
  51.     */
  52.     function Spreadsheet_Excel_Writer($filename '')
  53.     {
  54.         $this->_filename $filename;
  55.         $this->Spreadsheet_Excel_Writer_Workbook($filename);
  56.     }
  57.  
  58.     /**
  59.     * Send HTTP headers for the Excel file.
  60.     *
  61.     * @param string $filename The filename to use for HTTP headers
  62.     * @access public
  63.     */
  64.     function send($filename)
  65.     {
  66.         header("Content-type: application/vnd.ms-excel");
  67.         header("Content-Disposition: attachment; filename=\"$filename\"");
  68.         header("Expires: 0");
  69.         header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
  70.         header("Pragma: public");
  71.     }
  72.  
  73.     /**
  74.     * Utility function for writing formulas
  75.     * Converts a cell's coordinates to the A1 format.
  76.     *
  77.     * @access public
  78.     * @static
  79.     * @param integer $row Row for the cell to convert (0-indexed).
  80.     * @param integer $col Column for the cell to convert (0-indexed).
  81.     * @return string The cell identifier in A1 format
  82.     */
  83.     function rowcolToCell($row$col)
  84.     {
  85.         if ($col > 255//maximum column value exceeded
  86.             return new PEAR_Error("Maximum column value exceeded: $col");
  87.         }
  88.  
  89.         $int = (int)($col / 26);
  90.         $frac $col % 26;
  91.         $chr1 '';
  92.  
  93.         if ($int > 0{
  94.             $chr1 chr(ord('A'$int - 1);
  95.         }
  96.  
  97.         $chr2 chr(ord('A'$frac);
  98.         $row++;
  99.  
  100.         return $chr1 $chr2 $row;
  101.     }
  102. }
  103. ?>

Documentation generated on Mon, 11 Mar 2019 15:47:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.