1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
2 -------------------------------------------------------------------------------
5 -------------------------------------------------------------------------------
6 This file is part of meconlib.
8 meconlib is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your option)
13 meconlib is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License; if not,
18 write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Creado: Fri Oct 24 16:12:31 2003
22 Autor: Gonzalo Merayo <gmeray@mecon.gov.ar>
23 -------------------------------------------------------------------------------
24 $Id: PDF.php 428 2003-11-18 14:30:30Z mmarre $
25 -----------------------------------------------------------------------------*/
28 * Liberia base para el manejo de xls's.
32 * _xls_data, mantiene el binario temporal del xls
38 * _tabla, guarda una HTML_Tabla para obtener los datos
45 * MECON_XLS Constructor,
46 * @attrib tabla HTML_Tabla tabla de la que saca los datos
49 function MECON_XLS($tabla)
56 * @attrib row numero de fila
57 * @attrib col numero de columna
58 * @attrib value valor a poner en la celda
61 function _WriteNumber($row,$col,$value)
63 $this->_xls_data .= pack("sssss",0x0203,14,$row,$col,0x00);
64 $this->_xls_data .= pack("d",$value);
69 * @attrib row numero de fila
70 * @attrib col numero de columna
71 * @attrib value valor a poner en la celda
74 function _WriteText($row,$col,$value)
76 $len = strlen($value);
77 $this->_xls_data .= pack("s*",0x0204,8+$len,$row,$col,0x00,$len);
78 $this->_xls_data .= $value;
83 * @attrib row numero de fila
84 * @attrib col numero de columna
85 * @attrib value valor a poner en la celda
88 function _Write($row,$col,$value)
90 $tipo = gettype($value);
91 if($tipo == "integer" || $tipo == "double" || $tipo == "float")
92 $this->_WriteNumber($row,$col,$value);
93 $this->_WriteText($row,$col,$value);
98 * Funcion que genera el archivo y prepara los headers para que se envie.
105 header("Content-Disposition: filename=planilla.xls");
106 header("Content-Type: application/x-msexcel");
107 $tmp =& $this->toXLS();
108 header('Content-Length: ' . strlen($tmp));
113 * Funcion que devuelve el XLS.
119 $this->_xls_data = pack("ssssss",0x809,0x08,0x00,0x10,0x0,0x0);
120 for($i = 0; $i< $this->_tabla->getRowCount(); $i++)
121 for($j = 0; $j< $this->_tabla->getColCount(); $j++)
122 $this->_Write($i, $j, $this->_tabla->getCellContents($i, $j));
123 $this->_xls_data .= pack("ss",0x0A,0x00);
124 return $this->_xls_data;