From: Manuel Nazar Anchorena Date: Mon, 1 Dec 2003 17:26:55 +0000 (+0000) Subject: Agrego XLS a MECONLIB X-Git-Tag: svn_import~165 X-Git-Url: https://git.llucax.com/mecon/meconlib.git/commitdiff_plain/21fe94badb18ad1c99efb2649340ac9864e41122?ds=sidebyside;hp=7bf8c6564e60cc22ab1d2bd0ff46b26e2f26bbd8 Agrego XLS a MECONLIB --- diff --git a/lib/MECON/XLS.php b/lib/MECON/XLS.php new file mode 100644 index 0000000..32f508b --- /dev/null +++ b/lib/MECON/XLS.php @@ -0,0 +1,88 @@ + +------------------------------------------------------------------------------- +$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