Esempio n. 1
0
 public function jsonXlsAction()
 {
     if (!isset($this->_permissions['xls']) || !$this->_permissions['xls']) {
         throw new Kwf_Exception("XLS is not allowed.");
     }
     ini_set('memory_limit', "768M");
     set_time_limit(600);
     // 10 minuten
     $row = $this->_form->getRow();
     $primaryKey = $this->_form->getPrimaryKey();
     require_once Kwf_Config::getValue('externLibraryPath.phpexcel') . '/PHPExcel.php';
     $xls = new PHPExcel();
     $xls->getProperties()->setCreator(Kwf_Config::getValue('application.name'));
     $xls->getProperties()->setLastModifiedBy(Kwf_Config::getValue('application.name'));
     $xls->getProperties()->setTitle("KWF Excel Export");
     $xls->getProperties()->setSubject("KWF Excel Export");
     $xls->getProperties()->setDescription("KWF Excel Export");
     $xls->getProperties()->setKeywords("KWF Excel Export");
     $xls->getProperties()->setCategory("KWF Excel Export");
     $xls->setActiveSheetIndex(0);
     $sheet = $xls->getActiveSheet();
     $this->_progressBar = new Zend_ProgressBar(new Kwf_Util_ProgressBar_Adapter_Cache($this->_getParam('progressNum')), 0, count($this->_fields));
     $outputXls = $xls;
     if ($row && $primaryKey) {
         $outputXls = $this->_fillTheXlsFile($xls, $sheet);
     }
     if ($outputXls != NULL) {
         // write the file
         $objWriter = PHPExcel_IOFactory::createWriter($outputXls, 'Excel5');
     } else {
         // write the file
         $objWriter = PHPExcel_IOFactory::createWriter($xls, 'Excel5');
     }
     $downloadkey = uniqid();
     $objWriter->save('temp/' . $downloadkey . '.xls');
     $this->_progressBar->finish();
     $this->view->downloadkey = $downloadkey;
 }