コード例 #1
0
ファイル: Extended.php プロジェクト: nickimproove/magento2
 /**
  * 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);
 }
コード例 #2
0
ファイル: ExcelTest.php プロジェクト: natxetee/magento2
 /**
  * Write Data into File
  *
  * @param bool $callback
  * @return string
  */
 protected function _writeFile($callback = false)
 {
     $adapter = new Magento_Filesystem_Adapter_Local();
     $filesystem = new Magento_Filesystem($adapter);
     $name = md5(microtime());
     $file = TESTS_TEMP_DIR . DIRECTORY_SEPARATOR . $name . '.xml';
     $stream = $filesystem->createAndOpenStream($file, 'w+', TESTS_TEMP_DIR);
     $stream->lock(true);
     if (!$callback) {
         $convert = new Magento_Convert_Excel(new ArrayIterator($this->_testData));
     } else {
         $convert = new Magento_Convert_Excel(new ArrayIterator($this->_testData), array($this, 'callbackMethod'));
     }
     $convert->write($stream);
     $stream->unlock();
     $stream->close();
     return $file;
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
ファイル: ExcelTest.php プロジェクト: nemphys/magento2
 /**
  * Write Data into File
  *
  * @param bool $callback
  * @return string
  */
 protected function _writeFile($callback = false)
 {
     $ioFile = new Varien_Io_File();
     $path = Magento_Test_Environment::getInstance()->getTmpDir();
     $name = md5(microtime());
     $file = $path . DIRECTORY_SEPARATOR . $name . '.xml';
     $ioFile->open(array('path' => $path));
     $ioFile->streamOpen($file, 'w+');
     $ioFile->streamLock(true);
     if (!$callback) {
         $convert = new Magento_Convert_Excel(new ArrayIterator($this->_testData));
     } else {
         $convert = new Magento_Convert_Excel(new ArrayIterator($this->_testData), array($this, 'callbackMethod'));
     }
     $convert->write($ioFile);
     $ioFile->streamUnlock();
     $ioFile->streamClose();
     return $file;
 }