/** * Retrieve a file container array by grid data as MS Excel 2003 XML Document * * Return array with keys type and value * * @param string $sheetName * @return array */ public function getExcelFile($sheetName = '') { $this->_isExport = true; $this->_prepareGrid(); $convert = new Magento_Convert_Excel($this->getCollection()->getIterator(), array($this, 'getRowRecord')); $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); $convert->setDataHeader($this->_getExportHeaders()); if ($this->getCountTotals()) { $convert->setDataFooter($this->_getExportTotals()); } $convert->write($io, $sheetName); $io->streamUnlock(); $io->streamClose(); return array('type' => 'filename', 'value' => $file, 'rm' => true); }
/** * Retrieve a file container array by grid data as MS Excel 2003 XML Document * * Return array with keys type and value * * @param string $sheetName * @return array */ public function getExcelFile($sheetName = '') { $collection = $this->_getRowCollection(); $convert = new Magento_Convert_Excel($collection->getIterator(), array($this, 'getRowRecord')); $name = md5(microtime()); $file = $this->_exportPath . DS . $name . '.xml'; $this->_filesystem->setIsAllowCreateDirectories(true); $stream = $this->_filesystem->createAndOpenStream($file, 'w+', $this->_exportPath); $stream->lock(true); $convert->setDataHeader($this->_getExportHeaders()); if ($this->getCountTotals()) { $convert->setDataFooter($this->_getExportTotals()); } $convert->write($stream, $sheetName); $stream->unlock(); $stream->close(); return array('type' => 'filename', 'value' => $file, 'rm' => true); }