芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/asm/Classes/PHPExcel/Writer/Excel5.php
_preCalculateFormulas = true; $this->_phpExcel = $phpExcel; $this->_BIFF_version = 0x0600; $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); $this->_str_total = 0; $this->_str_unique = 0; $this->_str_table = array(); $this->_parser = new PHPExcel_Writer_Excel5_Parser($this->_BIFF_version); } /** * Save PHPExcel to file * * @param string $pFileName * @throws Exception */ public function save($pFilename = null) { // check mbstring.func_overload if (ini_get('mbstring.func_overload') != 0) { throw new Exception('Multibyte string function overloading in PHP must be disabled.'); } // garbage collect $this->_phpExcel->garbageCollect(); $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); // initialize colors array $this->_colors = array(); // Initialise workbook writer $this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_tempDir); // Initialise worksheet writers $countSheets = count($this->_phpExcel->getAllSheets()); for ($i = 0; $i < $countSheets; ++$i) { $phpSheet = $this->_phpExcel->getSheet($i); $writerWorksheet = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_tempDir, $this->_preCalculateFormulas, $phpSheet); $this->_writerWorksheets[$i] = $writerWorksheet; } // add 15 identical cell style Xfs // for now, we use the first cellXf instead of cellStyleXf $cellXfCollection = $this->_phpExcel->getCellXfCollection(); for ($i = 0; $i < 15; ++$i) { $this->_writerWorkbook->addXfWriter($cellXfCollection[0], true); } // add all the cell Xfs foreach ($this->_phpExcel->getCellXfCollection() as $style) { $this->_writerWorkbook->addXfWriter($style, false); } // initialize OLE file $workbookStreamName = ($this->_BIFF_version == 0x0600) ? 'Workbook' : 'Book'; $OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName)); if ($this->_tempDir != '') { $OLE->setTempDir($this->_tempDir); } $res = $OLE->init(); // Write the worksheet streams before the global workbook stream, // because the byte sizes of these are needed in the global workbook stream $worksheetSizes = array(); for ($i = 0; $i < $countSheets; ++$i) { $this->_writerWorksheets[$i]->close(); $worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize; } // add binary data for global workbook stream $OLE->append( $this->_writerWorkbook->writeWorkbook($worksheetSizes) ); // add binary data for sheet streams for ($i = 0; $i < $countSheets; ++$i) { while ( ($tmp = $this->_writerWorksheets[$i]->getData()) !== false ) { $OLE->append($tmp); } } $root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE)); if ($this->_tempDir != '') { $root->setTempDir($this->_tempDir); } // save the OLE file $res = $root->save($pFilename); PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType); // clean up foreach ($this->_writerWorksheets as $sheet) { $sheet->cleanup(); } } /** * Get temporary storage directory * * @return string */ public function getTempDir() { return $this->_tempDir; } /** * Set temporary storage directory * * @param string $pValue Temporary storage directory * @throws Exception Exception when directory does not exist * @return PHPExcel_Writer_Excel5 */ public function setTempDir($pValue = '') { if (is_dir($pValue)) { $this->_tempDir = $pValue; } else { throw new Exception("Directory does not exist: $pValue"); } return $this; } /** * Get Pre-Calculate Formulas * * @return boolean */ public function getPreCalculateFormulas() { return $this->_preCalculateFormulas; } /** * Set Pre-Calculate Formulas * * @param boolean $pValue Pre-Calculate Formulas? */ public function setPreCalculateFormulas($pValue = true) { $this->_preCalculateFormulas = $pValue; } }