_xml; } /** * * @return CreateExcelTable * @static */ public static function getInstance() { if (self::$_instance == NULL) { self::$_instance = new CreateExcelTable(); } return self::$_instance; } /** * Create excel table * * @access public * @param string args[0] * @param string args[1] */ public function createExcelTable() { $this->_xml = ''; $args = func_get_args(); $type = $args[1]; $dats = $args[0]; $tamDatos = count($dats); foreach ($dats as $ind => $data) { $tamCols = count($data); break; } $tamDatos = count($dats); if (strpos($type, 'pie') !== false) { $tamCols = 1; } else { $tamDatos--; } $this->generateTABLE($tamDatos, $tamCols); $this->generateTABLECOLUMNS($tamCols + 1); $this->generateTABLECOLUMN(1, ' '); for ($i = 0; $i < $tamCols; $i++) { if (strpos($type, 'pie') !== false) { $this->generateTABLECOLUMN($i + 2, '0'); break; }else $this->generateTABLECOLUMN($i + 2, $dats[0][$i]); } $this->generateTABLESTYLEINFO(); $this->cleanTemplate(); } /** * Generate table * * @param int $rows * @param int $cols * @access protected */ protected function generateTABLE($rows, $cols) { $chart = 'A'; for ($i = 0; $i < $cols; $i++) $chart++; $rows++; $this->_xml = ''. ''. '__GENERATETABLE__
'; } /** * Generate tablecolumns * * @param string $count * @access protected */ protected function generateTABLECOLUMNS($count = '2') { $xml = '__GENERATETABLECOLUMNS____GENERATETABLE__'; $this->_xml = str_replace('__GENERATETABLE__', $xml, $this->_xml); } /** * Generate tablecolumn * * @param string $id * @param string $name * @access protected */ protected function generateTABLECOLUMN($id = '2', $name = '') { $xml = '__GENERATETABLECOLUMNS__'; $this->_xml = str_replace( '__GENERATETABLECOLUMNS__', $xml, $this->_xml ); } /** * Generate tablestyleinfo * * @param string $showFirstColumn * @param string $showLastColumn * @param string $showRowStripes * @param string $showColumnStripes * @access protected */ protected function generateTABLESTYLEINFO($showFirstColumn = '0', $showLastColumn = "0", $showRowStripes = "1", $showColumnStripes = "0") { $xml = ''; $this->_xml = str_replace('__GENERATETABLE__', $xml, $this->_xml); } }