+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
+-------------------------------------------------------------------------------
+ Ministerio de EconomÃa
+ meconlib
+-------------------------------------------------------------------------------
+This file is part of meconlib.
+
+meconlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+meconlib is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA 02111-1307 USA
+-------------------------------------------------------------------------------
+Creado: Fri Oct 24 16:12:31 2003
+Autor: Gonzalo Merayo <gmeray@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id: PDF.php 428 2003-11-18 14:30:30Z mmarre $
+-----------------------------------------------------------------------------*/
+
+/**
+ * Liberia base para el manejo de xls's.
+ */
+class MECON_XLS {
+ var $_xls_data;
+ var $_tabla;
+ function MECON_XLS($tabla)
+ {
+ $this->_tabla=$tabla;
+ }
+
+ function _WriteNumber($row,$col,$value)
+ {
+ $this->_xls_data .= pack("sssss",0x0203,14,$row,$col,0x00);
+ $this->_xls_data .= pack("d",$value);
+ }
+
+ function _WriteText($row,$col,$value)
+ {
+ $len = strlen($value);
+ $this->_xls_data .= pack("s*",0x0204,8+$len,$row,$col,0x00,$len);
+ $this->_xls_data .= $value;
+ }
+
+ function _Write($row,$col,$value)
+ {
+ //TODO hacer que guarde segun si es un numero o un texto
+ $this->_WriteText($row,$col,$value);
+ }
+
+
+ /**
+ * Funcion que genera el archivo y prepara los headers para que se envie.
+ *
+ * @return void
+ * @access public
+ */
+ function display()
+ {
+ header("Content-Disposition: filename=planilla.xls");
+ header("Content-Type: application/x-msexcel");
+ $tmp =& $this->toXLS();
+ header('Content-Length: ' . strlen($tmp));
+ echo $tmp;
+ }
+
+ /**
+ * Funcion que devuelve el XLS.
+ *
+ * @return string
+ * @access public
+ */
+ function toXLS() {
+ $this->_xls_data = pack("ssssss",0x809,0x08,0x00,0x10,0x0,0x0);
+ for($i = 0; $i< $this->_tabla->getRowCount(); $i++)
+ for($j = 0; $j< $this->_tabla->getColCount(); $j++)
+ $this->_Write($i, $j, $this->_tabla->getCellContents($i, $j));
+ $this->_xls_data .= pack("ss",0x0A,0x00);
+ return $this->_xls_data;
+ }
+}
+?>
\ No newline at end of file