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