30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
38 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/IWriter.php';
41 require_once PHPEXCEL_ROOT .
'PHPExcel/Cell.php';
44 require_once PHPEXCEL_ROOT .
'PHPExcel/HashTable.php';
47 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/OLE/OLE_Root.php';
50 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/OLE/OLE_File.php';
53 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/Excel5/Parser.php';
56 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/Excel5/Workbook.php';
124 $this->_phpExcel = $phpExcel;
125 $this->_BIFF_version = 0x0600;
126 $this->_tempDir =
'';
128 $this->_str_total = 0;
129 $this->_str_unique = 0;
130 $this->_str_table = array();
141 public function save($pFilename = null) {
144 if (ini_get(
'mbstring.func_overload') != 0) {
145 throw new Exception(
'Multibyte string function overloading in PHP must be disabled.');
149 $this->_phpExcel->garbageCollect();
156 $this->_str_total, $this->_str_unique, $this->_str_table, $this->_parser, $this->_tempDir);
159 $countSheets = count($this->_phpExcel->getAllSheets());
160 for ($i = 0; $i < $countSheets; ++$i) {
161 $phpSheet = $this->_phpExcel->getSheet($i);
164 $this->_str_total, $this->_str_unique,
166 $this->_parser, $this->_tempDir,
168 $this->_writerWorksheets[$i] = $writerWorksheet;
173 $cellXfCollection = $this->_phpExcel->getCellXfCollection();
174 for ($i = 0; $i < 15; ++$i) {
175 $this->_writerWorkbook->addXfWriter($cellXfCollection[0],
true);
179 foreach ($this->_phpExcel->getCellXfCollection() as $style) {
180 $this->_writerWorkbook->addXfWriter($style,
false);
184 $workbookStreamName = ($this->_BIFF_version == 0x0600) ?
'Workbook' :
'Book';
187 if ($this->_tempDir !=
'') {
188 $OLE->setTempDir($this->_tempDir);
194 $worksheetSizes = array();
195 for ($i = 0; $i < $countSheets; ++$i) {
196 $this->_writerWorksheets[$i]->close();
197 $worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
201 $OLE->append( $this->_writerWorkbook->writeWorkbook($worksheetSizes) );
204 for ($i = 0; $i < $countSheets; ++$i) {
205 while ( ($tmp = $this->_writerWorksheets[$i]->getData()) !== false ) {
211 if ($this->_tempDir !=
'') {
212 $root->setTempDir($this->_tempDir);
216 $res = $root->save($pFilename);
221 foreach ($this->_writerWorksheets as $sheet) {
243 if (is_dir($pValue)) {
244 $this->_tempDir = $pValue;
246 throw new Exception(
"Directory does not exist: $pValue");