108 $this->_phpExcel = $phpExcel;
119 public function save($pFilename = null) {
122 $this->_phpExcel->garbageCollect();
130 $this->_colors = array();
134 $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
137 $countSheets = $this->_phpExcel->getSheetCount();
138 for ($i = 0; $i < $countSheets; ++$i) {
140 $this->_str_total, $this->_str_unique,
141 $this->_str_table, $this->_colors,
143 $this->_preCalculateFormulas,
144 $this->_phpExcel->getSheet($i));
153 $cellXfCollection = $this->_phpExcel->getCellXfCollection();
154 for ($i = 0; $i < 15; ++$i) {
155 $this->_writerWorkbook->addXfWriter($cellXfCollection[0],
true);
159 foreach ($this->_phpExcel->getCellXfCollection() as $style) {
160 $this->_writerWorkbook->addXfWriter($style,
false);
164 $workbookStreamName = ($this->_BIFF_version == 0x0600) ?
'Workbook' :
'Book';
169 $worksheetSizes = array();
170 for ($i = 0; $i < $countSheets; ++$i) {
171 $this->_writerWorksheets[$i]->close();
172 $worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
176 $OLE->append( $this->_writerWorkbook->writeWorkbook($worksheetSizes) );
179 for ($i = 0; $i < $countSheets; ++$i) {
180 $OLE->append($this->_writerWorksheets[$i]->getData());
185 $res = $root->save($pFilename);
218 $this->_preCalculateFormulas = $pValue;
226 foreach ($this->_phpExcel->getAllsheets() as $sheet) {
228 $sheetIndex = $sheet->getParent()->getIndex($sheet);
233 if (count($sheet->getDrawingCollection()) == 0) {
244 $dgId = $sheet->getParent()->getIndex($sheet) + 1;
245 $dgContainer->setDgId($dgId);
246 $escher->setDgContainer($dgContainer);
250 $dgContainer->setSpgrContainer($spgrContainer);
254 $spContainer->setSpgr(
true);
255 $spContainer->setSpType(0);
256 $spContainer->setSpId(($sheet->getParent()->getIndex($sheet) + 1) << 10);
257 $spgrContainer->addChild($spContainer);
261 $countShapes[$sheetIndex] = 0;
263 foreach ($sheet->getDrawingCollection() as $drawing) {
266 ++$countShapes[$sheetIndex];
272 $spContainer->setSpType(0x004B);
275 $reducedSpId = $countShapes[$sheetIndex];
277 | ($sheet->getParent()->getIndex($sheet) + 1) << 10;
278 $spContainer->setSpId($spId);
281 $lastReducedSpId = $reducedSpId;
287 $spContainer->setOPT(0x4104, $blipIndex);
290 $coordinates = $drawing->getCoordinates();
291 $offsetX = $drawing->getOffsetX();
292 $offsetY = $drawing->getOffsetY();
293 $width = $drawing->getWidth();
294 $height = $drawing->getHeight();
298 $spContainer->setStartCoordinates($twoAnchor[
'startCoordinates']);
299 $spContainer->setStartOffsetX($twoAnchor[
'startOffsetX']);
300 $spContainer->setStartOffsetY($twoAnchor[
'startOffsetY']);
301 $spContainer->setEndCoordinates($twoAnchor[
'endCoordinates']);
302 $spContainer->setEndOffsetX($twoAnchor[
'endOffsetX']);
303 $spContainer->setEndOffsetY($twoAnchor[
'endOffsetY']);
305 $spgrContainer->addChild($spContainer);
309 $this->_IDCLs[$dgId] = $lastReducedSpId;
312 $dgContainer->setLastSpId($lastSpId);
315 $this->_writerWorksheets[$sheetIndex]->setEscher($escher);
328 foreach ($this->_phpExcel->getAllSheets() as $sheet) {
329 if (count($sheet->getDrawingCollection()) > 0) {
344 $escher->setDggContainer($dggContainer);
347 $dggContainer->setIDCLs($this->_IDCLs);
351 $totalCountShapes = 0;
354 foreach ($this->_phpExcel->getAllsheets() as $sheet) {
355 $sheetCountShapes = 0;
357 if (count($sheet->getDrawingCollection()) > 0) {
360 foreach ($sheet->getDrawingCollection() as $drawing) {
364 $spId = $sheetCountShapes
365 | ($this->_phpExcel->getIndex($sheet) + 1) << 10;
366 $spIdMax = max($spId, $spIdMax);
371 $dggContainer->setSpIdMax($spIdMax + 1);
372 $dggContainer->setCDgSaved($countDrawings);
373 $dggContainer->setCSpSaved($totalCountShapes + $countDrawings);
377 $dggContainer->setBstoreContainer($bstoreContainer);
380 foreach ($this->_phpExcel->getAllsheets() as $sheet) {
381 foreach ($sheet->getDrawingCollection() as $drawing) {
386 list($imagesx, $imagesy, $imageFormat) = getimagesize(
$filename);
388 switch ($imageFormat) {
394 $blipData = ob_get_contents();
400 $blipData = file_get_contents(
$filename);
405 $blipData = file_get_contents(
$filename);
412 $blipData = ob_get_contents();
421 $blip->setData($blipData);
424 $BSE->setBlipType($blipType);
425 $BSE->setBlip($blip);
427 $bstoreContainer->addBSE($BSE);
431 switch ($drawing->getRenderingFunction()) {
435 $renderingFunction =
'imagejpeg';
442 $renderingFunction =
'imagepng';
448 call_user_func($renderingFunction, $drawing->getImageResource());
449 $blipData = ob_get_contents();
453 $blip->setData($blipData);
456 $BSE->setBlipType($blipType);
457 $BSE->setBlip($blip);
459 $bstoreContainer->addBSE($BSE);
465 $this->_writerWorkbook->setEscher($escher);