Exemplo n.º 1
0
 /**
  * Retrieve a file container array by grid data as MS Excel 2003 XML Document
  *
  * Return array with keys type and value
  *
  * @return string
  */
 public function getExcelFile($sheetName = '')
 {
     $this->_isExport = true;
     $this->_prepareGrid();
     $parser = new Varien_Convert_Parser_Xml_Excel();
     $io = new Varien_Io_File();
     $path = Mage::getBaseDir('var') . DS . 'export' . DS;
     $name = md5(microtime());
     $file = $path . DS . $name . '.xml';
     $io->setAllowCreateFolders(true);
     $io->open(array('path' => $path));
     $io->streamOpen($file, 'w+');
     $io->streamLock(true);
     $io->streamWrite($parser->getHeaderXml($sheetName));
     $io->streamWrite($parser->getRowXml($this->_getExportHeaders()));
     $this->_exportIterateCollection('_exportExcelItem', array($io, $parser));
     if ($this->getCountTotals()) {
         $io->streamWrite($parser->getRowXml($this->_getExportTotals()));
     }
     $io->streamWrite($parser->getFooterXml());
     $io->streamUnlock();
     $io->streamClose();
     return array('type' => 'filename', 'value' => $file, 'rm' => true);
 }