ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_Writer_Excel5_Workbook Class Reference
+ Inheritance diagram for PHPExcel_Writer_Excel5_Workbook:
+ Collaboration diagram for PHPExcel_Writer_Excel5_Workbook:

Public Member Functions

 __construct (PHPExcel $phpExcel=null, &$str_total, &$str_unique, &$str_table, &$colors, $parser)
 Class constructor. More...
 
 addXfWriter ($style, $isStyleXf=false)
 Add a new XF writer. More...
 
 _addFont (PHPExcel_Style_Font $font)
 Add a font to added fonts. More...
 
 _setPaletteXl97 ()
 Sets the colour palette to the Excel 97+ default. More...
 
 writeWorkbook ($pWorksheetSizes=null)
 Assemble worksheets into a workbook and send the BIFF data to an OLE storage. More...
 
 _calcSheetOffsets ()
 Calculate offsets for Worksheet BOF records. More...
 
 getEscher ()
 Get Escher object. More...
 
 setEscher (PHPExcel_Shared_Escher $pValue=null)
 Set Escher object. More...
 
- Public Member Functions inherited from PHPExcel_Writer_Excel5_BIFFwriter
 __construct ()
 Constructor. More...
 
 _append ($data)
 General storage function. More...
 
 writeData ($data)
 General storage function like _append, but returns string instead of modifying $this->_data. More...
 
 _storeBof ($type)
 Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file. More...
 
 _storeEof ()
 Writes Excel EOF record to indicate the end of a BIFF stream. More...
 
 writeEof ()
 Writes Excel EOF record to indicate the end of a BIFF stream. More...
 
 _addContinue ($data)
 Excel limits the size of BIFF records. More...
 

Data Fields

 $_biffsize
 
 $_palette
 
 $_codepage
 
 $_country_code
 
- Data Fields inherited from PHPExcel_Writer_Excel5_BIFFwriter
 $_data
 
 $_datasize
 
 $_limit = 8224
 

Private Member Functions

 _addColor ($rgb)
 Alter color palette adding a custom color. More...
 
 _writeAllFonts ()
 Store the Excel FONT records. More...
 
 _writeAllNumFormats ()
 Store user defined numerical formats i.e. More...
 
 _writeAllXfs ()
 Write all XF records. More...
 
 _writeAllStyles ()
 Write all STYLE records. More...
 
 _writeExterns ()
 Write the EXTERNCOUNT and EXTERNSHEET records. More...
 
 _writeNames ()
 Write the NAME record to define the print area and the repeat rows and cols. More...
 
 _writeAllDefinedNamesBiff8 ()
 Writes all the DEFINEDNAME records (BIFF8). More...
 
 _writeDefinedNameBiff8 ($name, $formulaData, $sheetIndex=0, $isBuiltIn=false)
 Write a DEFINEDNAME record for BIFF8 using explicit binary formula data. More...
 
 _writeShortNameBiff8 ($name, $sheetIndex=0, $rangeBounds, $isHidden=false)
 Write a short NAME record. More...
 
 _writeCodepage ()
 Stores the CODEPAGE biff record. More...
 
 _writeWindow1 ()
 Write Excel BIFF WINDOW1 record. More...
 
 _writeBoundsheet ($sheet, $offset)
 Writes Excel BIFF BOUNDSHEET record. More...
 
 _writeSupbookInternal ()
 Write Internal SUPBOOK record. More...
 
 _writeExternsheetBiff8 ()
 Writes the Excel BIFF EXTERNSHEET record. More...
 
 _writeStyle ()
 Write Excel BIFF STYLE records. More...
 
 _writeNumFormat ($format, $ifmt)
 Writes Excel FORMAT record for non "built-in" numerical formats. More...
 
 _writeDatemode ()
 Write DATEMODE record to indicate the date system in use (1904 or 1900). More...
 
 _writeExterncount ($cxals)
 Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in the workbook. More...
 
 _writeExternsheet ($sheetname)
 Writes the Excel BIFF EXTERNSHEET record. More...
 
 _writeNameShort ($index, $type, $rowmin, $rowmax, $colmin, $colmax)
 Store the NAME record in the short format that is used for storing the print area, repeat rows only and repeat columns only. More...
 
 _writeNameLong ($index, $type, $rowmin, $rowmax, $colmin, $colmax)
 Store the NAME record in the long format that is used for storing the repeat rows and columns when both are specified. More...
 
 _writeCountry ()
 Stores the COUNTRY record for localization. More...
 
 _writeRecalcId ()
 Write the RECALCID record. More...
 
 _writePalette ()
 Stores the PALETTE biff record. More...
 
 _writeSharedStringsTable ()
 Handling of the SST continue blocks is complicated by the need to include an additional continuation byte depending on whether the string is split between blocks or whether it starts at the beginning of the block. More...
 
 _writeMsoDrawingGroup ()
 Writes the MSODRAWINGGROUP record if needed. More...
 

Private Attributes

 $_parser
 
 $_xfWriters = array()
 
 $_phpExcel
 
 $_fontWriters = array()
 
 $_addedFonts = array()
 
 $_numberFormats = array()
 
 $_addedNumberFormats = array()
 
 $_worksheetSizes = array()
 
 $_worksheetOffsets = array()
 
 $_str_total
 
 $_str_unique
 
 $_str_table
 
 $_colors
 Color cache. More...
 
 $_escher
 

Additional Inherited Members

- Static Public Member Functions inherited from PHPExcel_Writer_Excel5_BIFFwriter
static getByteOrder ()
 Determine the byte order and store it as class data to avoid recalculating it for each call to new(). More...
 

Detailed Description

Definition at line 71 of file Workbook.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_Writer_Excel5_Workbook::__construct ( PHPExcel  $phpExcel = null,
$str_total,
$str_unique,
$str_table,
$colors,
  $parser 
)

Class constructor.

Parameters
PHPExcel$phpExcelThe Workbook
int&$str_totalTotal number of strings
int&$str_uniqueTotal number of unique strings
array&$str_tableString Table
array&$colorsColour Table
mixed$parserThe formula parser created for the Workbook

Definition at line 203 of file Workbook.php.

206 {
207 // It needs to call its parent's constructor explicitly
208 parent::__construct();
209
210 $this->_parser = $parser;
211 $this->_biffsize = 0;
212 $this->_palette = array();
213 $this->_country_code = -1;
214
215 $this->_str_total = &$str_total;
216 $this->_str_unique = &$str_unique;
217 $this->_str_table = &$str_table;
218 $this->_colors = &$colors;
219 $this->_setPaletteXl97();
220
221 $this->_phpExcel = $phpExcel;
222
223 // set BIFFwriter limit for CONTINUE records
224 // $this->_limit = 8224;
225 $this->_codepage = 0x04B0;
226
227 // Add empty sheets and Build color cache
228 $countSheets = $phpExcel->getSheetCount();
229 for ($i = 0; $i < $countSheets; ++$i) {
230 $phpSheet = $phpExcel->getSheet($i);
231
232 $this->_parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser
233
234 $supbook_index = 0x00;
235 $ref = pack('vvv', $supbook_index, $i, $i);
236 $this->_parser->_references[] = $ref; // Register reference with parser
237
238 // Sheet tab colors?
239 if ($phpSheet->isTabColorSet()) {
240 $this->_addColor($phpSheet->getTabColor()->getRGB());
241 }
242 }
243
244 }
$parser
Definition: BPMN2Parser.php:24
_addColor($rgb)
Alter color palette adding a custom color.
Definition: Workbook.php:327
_setPaletteXl97()
Sets the colour palette to the Excel 97+ default.
Definition: Workbook.php:357
getSheetCount()
Get sheet count.
Definition: PHPExcel.php:661
getSheet($pIndex=0)
Get sheet by index.
Definition: PHPExcel.php:573

References $parser, _addColor(), and _setPaletteXl97().

+ Here is the call graph for this function:

Member Function Documentation

◆ _addColor()

PHPExcel_Writer_Excel5_Workbook::_addColor (   $rgb)
private

Alter color palette adding a custom color.

Parameters
string$rgbE.g. 'FF00AA'
Returns
int Color index

Definition at line 327 of file Workbook.php.

327 {
328 if (!isset($this->_colors[$rgb])) {
329 if (count($this->_colors) < 57) {
330 // then we add a custom color altering the palette
331 $colorIndex = 8 + count($this->_colors);
332 $this->_palette[$colorIndex] =
333 array(
334 hexdec(substr($rgb, 0, 2)),
335 hexdec(substr($rgb, 2, 2)),
336 hexdec(substr($rgb, 4)),
337 0
338 );
339 $this->_colors[$rgb] = $colorIndex;
340 } else {
341 // no room for more custom colors, just map to black
342 $colorIndex = 0;
343 }
344 } else {
345 // fetch already added custom color
346 $colorIndex = $this->_colors[$rgb];
347 }
348
349 return $colorIndex;
350 }

Referenced by __construct(), _addFont(), and addXfWriter().

+ Here is the caller graph for this function:

◆ _addFont()

PHPExcel_Writer_Excel5_Workbook::_addFont ( PHPExcel_Style_Font  $font)

Add a font to added fonts.

Parameters
PHPExcel_Style_Font$font
Returns
int Index to FONT record

Definition at line 303 of file Workbook.php.

304 {
305 $fontHashCode = $font->getHashCode();
306 if(isset($this->_addedFonts[$fontHashCode])){
307 $fontIndex = $this->_addedFonts[$fontHashCode];
308 } else {
309 $countFonts = count($this->_fontWriters);
310 $fontIndex = ($countFonts < 4) ? $countFonts : $countFonts + 1;
311
312 $fontWriter = new PHPExcel_Writer_Excel5_Font($font);
313 $fontWriter->setColorIndex($this->_addColor($font->getColor()->getRGB()));
314 $this->_fontWriters[] = $fontWriter;
315
316 $this->_addedFonts[$fontHashCode] = $fontIndex;
317 }
318 return $fontIndex;
319 }
getHashCode()
Get hash code.
Definition: Font.php:514
getColor()
Get Color.
Definition: Font.php:485

References _addColor(), PHPExcel_Style_Font\getColor(), and PHPExcel_Style_Font\getHashCode().

Referenced by addXfWriter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _calcSheetOffsets()

PHPExcel_Writer_Excel5_Workbook::_calcSheetOffsets ( )

Calculate offsets for Worksheet BOF records.

@access private

Definition at line 480 of file Workbook.php.

481 {
482 $boundsheet_length = 10; // fixed length for a BOUNDSHEET record
483
484 // size of Workbook globals part 1 + 3
485 $offset = $this->_datasize;
486
487 // add size of Workbook globals part 2, the length of the SHEET records
488 $total_worksheets = count($this->_phpExcel->getAllSheets());
489 foreach ($this->_phpExcel->getWorksheetIterator() as $sheet) {
490 $offset += $boundsheet_length + strlen(PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheet->getTitle()));
491 }
492
493 // add the sizes of each of the Sheet substreams, respectively
494 for ($i = 0; $i < $total_worksheets; ++$i) {
495 $this->_worksheetOffsets[$i] = $offset;
496 $offset += $this->_worksheetSizes[$i];
497 }
498 $this->_biffsize = $offset;
499 }
static UTF8toBIFF8UnicodeShort($value, $arrcRuns=array())
Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) Writes the string using ...
Definition: String.php:434

References PHPExcel_Writer_Excel5_BIFFwriter\$_datasize, and PHPExcel_Shared_String\UTF8toBIFF8UnicodeShort().

Referenced by writeWorkbook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _setPaletteXl97()

PHPExcel_Writer_Excel5_Workbook::_setPaletteXl97 ( )

Sets the colour palette to the Excel 97+ default.

@access private

Definition at line 357 of file Workbook.php.

358 {
359 $this->_palette = array(
360 0x08 => array(0x00, 0x00, 0x00, 0x00),
361 0x09 => array(0xff, 0xff, 0xff, 0x00),
362 0x0A => array(0xff, 0x00, 0x00, 0x00),
363 0x0B => array(0x00, 0xff, 0x00, 0x00),
364 0x0C => array(0x00, 0x00, 0xff, 0x00),
365 0x0D => array(0xff, 0xff, 0x00, 0x00),
366 0x0E => array(0xff, 0x00, 0xff, 0x00),
367 0x0F => array(0x00, 0xff, 0xff, 0x00),
368 0x10 => array(0x80, 0x00, 0x00, 0x00),
369 0x11 => array(0x00, 0x80, 0x00, 0x00),
370 0x12 => array(0x00, 0x00, 0x80, 0x00),
371 0x13 => array(0x80, 0x80, 0x00, 0x00),
372 0x14 => array(0x80, 0x00, 0x80, 0x00),
373 0x15 => array(0x00, 0x80, 0x80, 0x00),
374 0x16 => array(0xc0, 0xc0, 0xc0, 0x00),
375 0x17 => array(0x80, 0x80, 0x80, 0x00),
376 0x18 => array(0x99, 0x99, 0xff, 0x00),
377 0x19 => array(0x99, 0x33, 0x66, 0x00),
378 0x1A => array(0xff, 0xff, 0xcc, 0x00),
379 0x1B => array(0xcc, 0xff, 0xff, 0x00),
380 0x1C => array(0x66, 0x00, 0x66, 0x00),
381 0x1D => array(0xff, 0x80, 0x80, 0x00),
382 0x1E => array(0x00, 0x66, 0xcc, 0x00),
383 0x1F => array(0xcc, 0xcc, 0xff, 0x00),
384 0x20 => array(0x00, 0x00, 0x80, 0x00),
385 0x21 => array(0xff, 0x00, 0xff, 0x00),
386 0x22 => array(0xff, 0xff, 0x00, 0x00),
387 0x23 => array(0x00, 0xff, 0xff, 0x00),
388 0x24 => array(0x80, 0x00, 0x80, 0x00),
389 0x25 => array(0x80, 0x00, 0x00, 0x00),
390 0x26 => array(0x00, 0x80, 0x80, 0x00),
391 0x27 => array(0x00, 0x00, 0xff, 0x00),
392 0x28 => array(0x00, 0xcc, 0xff, 0x00),
393 0x29 => array(0xcc, 0xff, 0xff, 0x00),
394 0x2A => array(0xcc, 0xff, 0xcc, 0x00),
395 0x2B => array(0xff, 0xff, 0x99, 0x00),
396 0x2C => array(0x99, 0xcc, 0xff, 0x00),
397 0x2D => array(0xff, 0x99, 0xcc, 0x00),
398 0x2E => array(0xcc, 0x99, 0xff, 0x00),
399 0x2F => array(0xff, 0xcc, 0x99, 0x00),
400 0x30 => array(0x33, 0x66, 0xff, 0x00),
401 0x31 => array(0x33, 0xcc, 0xcc, 0x00),
402 0x32 => array(0x99, 0xcc, 0x00, 0x00),
403 0x33 => array(0xff, 0xcc, 0x00, 0x00),
404 0x34 => array(0xff, 0x99, 0x00, 0x00),
405 0x35 => array(0xff, 0x66, 0x00, 0x00),
406 0x36 => array(0x66, 0x66, 0x99, 0x00),
407 0x37 => array(0x96, 0x96, 0x96, 0x00),
408 0x38 => array(0x00, 0x33, 0x66, 0x00),
409 0x39 => array(0x33, 0x99, 0x66, 0x00),
410 0x3A => array(0x00, 0x33, 0x00, 0x00),
411 0x3B => array(0x33, 0x33, 0x00, 0x00),
412 0x3C => array(0x99, 0x33, 0x00, 0x00),
413 0x3D => array(0x99, 0x33, 0x66, 0x00),
414 0x3E => array(0x33, 0x33, 0x99, 0x00),
415 0x3F => array(0x33, 0x33, 0x33, 0x00),
416 );
417 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ _writeAllDefinedNamesBiff8()

PHPExcel_Writer_Excel5_Workbook::_writeAllDefinedNamesBiff8 ( )
private

Writes all the DEFINEDNAME records (BIFF8).

So far this is only used for repeating rows/columns (print titles) and print areas

Definition at line 652 of file Workbook.php.

653 {
654 $chunk = '';
655
656 // Named ranges
657 if (count($this->_phpExcel->getNamedRanges()) > 0) {
658 // Loop named ranges
659 $namedRanges = $this->_phpExcel->getNamedRanges();
660 foreach ($namedRanges as $namedRange) {
661
662 // Create absolute coordinate
663 $range = PHPExcel_Cell::splitRange($namedRange->getRange());
664 for ($i = 0; $i < count($range); $i++) {
665 $range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteCoordinate($range[$i][0]);
666 if (isset($range[$i][1])) {
667 $range[$i][1] = PHPExcel_Cell::absoluteCoordinate($range[$i][1]);
668 }
669 }
670 $range = PHPExcel_Cell::buildRange($range); // e.g. Sheet1!$A$1:$B$2
671
672 // parse formula
673 try {
674 $error = $this->_parser->parse($range);
675 $formulaData = $this->_parser->toReversePolish();
676
677 // make sure tRef3d is of type tRef3dR (0x3A)
678 if (isset($formulaData{0}) and ($formulaData{0} == "\x7A" or $formulaData{0} == "\x5A")) {
679 $formulaData = "\x3A" . substr($formulaData, 1);
680 }
681
682 if ($namedRange->getLocalOnly()) {
683 // local scope
684 $scope = $this->_phpExcel->getIndex($namedRange->getScope()) + 1;
685 } else {
686 // global scope
687 $scope = 0;
688 }
689 $chunk .= $this->writeData($this->_writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false));
690
691 } catch(PHPExcel_Exception $e) {
692 // do nothing
693 }
694 }
695 }
696
697 // total number of sheets
698 $total_worksheets = $this->_phpExcel->getSheetCount();
699
700 // write the print titles (repeating rows, columns), if any
701 for ($i = 0; $i < $total_worksheets; ++$i) {
702 $sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup();
703 // simultaneous repeatColumns repeatRows
704 if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) {
705 $repeat = $sheetSetup->getColumnsToRepeatAtLeft();
706 $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
707 $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;
708
709 $repeat = $sheetSetup->getRowsToRepeatAtTop();
710 $rowmin = $repeat[0] - 1;
711 $rowmax = $repeat[1] - 1;
712
713 // construct formula data manually
714 $formulaData = pack('Cv', 0x29, 0x17); // tMemFunc
715 $formulaData .= pack('Cvvvvv', 0x3B, $i, 0, 65535, $colmin, $colmax); // tArea3d
716 $formulaData .= pack('Cvvvvv', 0x3B, $i, $rowmin, $rowmax, 0, 255); // tArea3d
717 $formulaData .= pack('C', 0x10); // tList
718
719 // store the DEFINEDNAME record
720 $chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true));
721
722 // (exclusive) either repeatColumns or repeatRows
723 } else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
724
725 // Columns to repeat
726 if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
727 $repeat = $sheetSetup->getColumnsToRepeatAtLeft();
728 $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
729 $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;
730 } else {
731 $colmin = 0;
732 $colmax = 255;
733 }
734 // Rows to repeat
735 if ($sheetSetup->isRowsToRepeatAtTopSet()) {
736 $repeat = $sheetSetup->getRowsToRepeatAtTop();
737 $rowmin = $repeat[0] - 1;
738 $rowmax = $repeat[1] - 1;
739 } else {
740 $rowmin = 0;
741 $rowmax = 65535;
742 }
743
744 // construct formula data manually because parser does not recognize absolute 3d cell references
745 $formulaData = pack('Cvvvvv', 0x3B, $i, $rowmin, $rowmax, $colmin, $colmax);
746
747 // store the DEFINEDNAME record
748 $chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x07), $formulaData, $i + 1, true));
749 }
750 }
751
752 // write the print areas, if any
753 for ($i = 0; $i < $total_worksheets; ++$i) {
754 $sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup();
755 if ($sheetSetup->isPrintAreaSet()) {
756 // Print area, e.g. A3:J6,H1:X20
757 $printArea = PHPExcel_Cell::splitRange($sheetSetup->getPrintArea());
758 $countPrintArea = count($printArea);
759
760 $formulaData = '';
761 for ($j = 0; $j < $countPrintArea; ++$j) {
762 $printAreaRect = $printArea[$j]; // e.g. A3:J6
763 $printAreaRect[0] = PHPExcel_Cell::coordinateFromString($printAreaRect[0]);
764 $printAreaRect[1] = PHPExcel_Cell::coordinateFromString($printAreaRect[1]);
765
766 $print_rowmin = $printAreaRect[0][1] - 1;
767 $print_rowmax = $printAreaRect[1][1] - 1;
768 $print_colmin = PHPExcel_Cell::columnIndexFromString($printAreaRect[0][0]) - 1;
769 $print_colmax = PHPExcel_Cell::columnIndexFromString($printAreaRect[1][0]) - 1;
770
771 // construct formula data manually because parser does not recognize absolute 3d cell references
772 $formulaData .= pack('Cvvvvv', 0x3B, $i, $print_rowmin, $print_rowmax, $print_colmin, $print_colmax);
773
774 if ($j > 0) {
775 $formulaData .= pack('C', 0x10); // list operator token ','
776 }
777 }
778
779 // store the DEFINEDNAME record
780 $chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x06), $formulaData, $i + 1, true));
781 }
782 }
783
784 // write autofilters, if any
785 for ($i = 0; $i < $total_worksheets; ++$i) {
786 $sheetAutoFilter = $this->_phpExcel->getSheet($i)->getAutoFilter();
787 $autoFilterRange = $sheetAutoFilter->getRange();
788 if(!empty($autoFilterRange)) {
789 $rangeBounds = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
790
791 //Autofilter built in name
792 $name = pack('C', 0x0D);
793
794 $chunk .= $this->writeData($this->_writeShortNameBiff8($name, $i + 1, $rangeBounds, true));
795 }
796 }
797
798 return $chunk;
799 }
static splitRange($pRange='A1:A1')
Split range into coordinate strings.
Definition: Cell.php:660

References PHPExcel_Cell\splitRange().

Referenced by writeWorkbook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeAllFonts()

PHPExcel_Writer_Excel5_Workbook::_writeAllFonts ( )
private

Store the Excel FONT records.

Definition at line 504 of file Workbook.php.

505 {
506 foreach ($this->_fontWriters as $fontWriter) {
507 $this->_append($fontWriter->writeFont());
508 }
509 }
_append($data)
General storage function.
Definition: BIFFwriter.php:139

References PHPExcel_Writer_Excel5_BIFFwriter\_append().

Referenced by writeWorkbook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeAllNumFormats()

PHPExcel_Writer_Excel5_Workbook::_writeAllNumFormats ( )
private

Store user defined numerical formats i.e.

FORMAT records

Definition at line 514 of file Workbook.php.

515 {
516 foreach ($this->_numberFormats as $numberFormatIndex => $numberFormat) {
517 $this->_writeNumFormat($numberFormat->getFormatCode(), $numberFormatIndex);
518 }
519 }
_writeNumFormat($format, $ifmt)
Writes Excel FORMAT record for non "built-in" numerical formats.
Definition: Workbook.php:1007

References _writeNumFormat().

Referenced by writeWorkbook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeAllStyles()

PHPExcel_Writer_Excel5_Workbook::_writeAllStyles ( )
private

Write all STYLE records.

Definition at line 534 of file Workbook.php.

535 {
536 $this->_writeStyle();
537 }
_writeStyle()
Write Excel BIFF STYLE records.
Definition: Workbook.php:987

References _writeStyle().

Referenced by writeWorkbook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeAllXfs()

PHPExcel_Writer_Excel5_Workbook::_writeAllXfs ( )
private

Write all XF records.

Definition at line 524 of file Workbook.php.

525 {
526 foreach ($this->_xfWriters as $xfWriter) {
527 $this->_append($xfWriter->writeXf());
528 }
529 }

References PHPExcel_Writer_Excel5_BIFFwriter\_append().

Referenced by writeWorkbook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeBoundsheet()

PHPExcel_Writer_Excel5_Workbook::_writeBoundsheet (   $sheet,
  $offset 
)
private

Writes Excel BIFF BOUNDSHEET record.

Parameters
PHPExcel_Worksheet$sheetWorksheet name
integer$offsetLocation of worksheet BOF

Definition at line 925 of file Workbook.php.

926 {
927 $sheetname = $sheet->getTitle();
928 $record = 0x0085; // Record identifier
929
930 // sheet state
931 switch ($sheet->getSheetState()) {
932 case PHPExcel_Worksheet::SHEETSTATE_VISIBLE: $ss = 0x00; break;
933 case PHPExcel_Worksheet::SHEETSTATE_HIDDEN: $ss = 0x01; break;
934 case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN: $ss = 0x02; break;
935 default: $ss = 0x00; break;
936 }
937
938 // sheet type
939 $st = 0x00;
940
941 $grbit = 0x0000; // Visibility and sheet type
942
943 $data = pack("VCC", $offset, $ss, $st);
945
946 $length = strlen($data);
947 $header = pack("vv", $record, $length);
948 $this->_append($header . $data);
949 }
const SHEETSTATE_HIDDEN
Definition: Worksheet.php:45
const SHEETSTATE_VERYHIDDEN
Definition: Worksheet.php:46
const SHEETSTATE_VISIBLE
Definition: Worksheet.php:44
$header

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeCodepage()

PHPExcel_Writer_Excel5_Workbook::_writeCodepage ( )
private

Stores the CODEPAGE biff record.

Definition at line 875 of file Workbook.php.

876 {
877 $record = 0x0042; // Record identifier
878 $length = 0x0002; // Number of bytes to follow
879 $cv = $this->_codepage; // The code page
880
881 $header = pack('vv', $record, $length);
882 $data = pack('v', $cv);
883
884 $this->_append($header . $data);
885 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeCountry()

PHPExcel_Writer_Excel5_Workbook::_writeCountry ( )
private

Stores the COUNTRY record for localization.

Returns
string

Definition at line 1230 of file Workbook.php.

1231 {
1232 $record = 0x008C; // Record identifier
1233 $length = 4; // Number of bytes to follow
1234
1235 $header = pack('vv', $record, $length);
1236 /* using the same country code always for simplicity */
1237 $data = pack('vv', $this->_country_code, $this->_country_code);
1238 //$this->_append($header . $data);
1239 return $this->writeData($header . $data);
1240 }
writeData($data)
General storage function like _append, but returns string instead of modifying $this->_data.
Definition: BIFFwriter.php:154

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeDatemode()

PHPExcel_Writer_Excel5_Workbook::_writeDatemode ( )
private

Write DATEMODE record to indicate the date system in use (1904 or 1900).

Definition at line 1023 of file Workbook.php.

1024 {
1025 $record = 0x0022; // Record identifier
1026 $length = 0x0002; // Bytes to follow
1027
1029 1 : 0; // Flag for 1904 date system
1030
1031 $header = pack("vv", $record, $length);
1032 $data = pack("v", $f1904);
1033 $this->_append($header . $data);
1034 }
const CALENDAR_MAC_1904
Definition: Date.php:41
static getExcelCalendar()
Return the Excel calendar (Windows 1900 or Mac 1904)
Definition: Date.php:106

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeDefinedNameBiff8()

PHPExcel_Writer_Excel5_Workbook::_writeDefinedNameBiff8 (   $name,
  $formulaData,
  $sheetIndex = 0,
  $isBuiltIn = false 
)
private

Write a DEFINEDNAME record for BIFF8 using explicit binary formula data.

Parameters
string$nameThe name in UTF-8
string$formulaDataThe binary formula data
string$sheetIndex1-based sheet index the defined name applies to. 0 = global
boolean$isBuiltInBuilt-in name?
Returns
string Complete binary record data

Definition at line 810 of file Workbook.php.

811 {
812 $record = 0x0018;
813
814 // option flags
815 $options = $isBuiltIn ? 0x20 : 0x00;
816
817 // length of the name, character count
819
820 // name with stripped length field
821 $name = substr(PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($name), 2);
822
823 // size of the formula (in bytes)
824 $sz = strlen($formulaData);
825
826 // combine the parts
827 $data = pack('vCCvvvCCCC', $options, 0, $nlen, $sz, 0, $sheetIndex, 0, 0, 0, 0)
828 . $name . $formulaData;
829 $length = strlen($data);
830
831 $header = pack('vv', $record, $length);
832
833 return $header . $data;
834 }
static CountCharacters($value, $enc='UTF-8')
Get character count.
Definition: String.php:550
static UTF8toBIFF8UnicodeLong($value)
Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) Writes the string using...
Definition: String.php:469
if(!is_array($argv)) $options

◆ _writeExterncount()

PHPExcel_Writer_Excel5_Workbook::_writeExterncount (   $cxals)
private

Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in the workbook.

Excel only stores references to external sheets that are used in NAME. The workbook NAME record is required to define the print area and the repeat rows and columns.

A similar method is used in Worksheet.php for a slightly different purpose.

Parameters
integer$cxalsNumber of external references

Definition at line 1048 of file Workbook.php.

1049 {
1050 $record = 0x0016; // Record identifier
1051 $length = 0x0002; // Number of bytes to follow
1052
1053 $header = pack("vv", $record, $length);
1054 $data = pack("v", $cxals);
1055 $this->_append($header . $data);
1056 }

Referenced by _writeExterns().

+ Here is the caller graph for this function:

◆ _writeExterns()

PHPExcel_Writer_Excel5_Workbook::_writeExterns ( )
private

Write the EXTERNCOUNT and EXTERNSHEET records.

These are used as indexes for the NAME records.

Definition at line 543 of file Workbook.php.

544 {
545 $countSheets = $this->_phpExcel->getSheetCount();
546 // Create EXTERNCOUNT with number of worksheets
547 $this->_writeExterncount($countSheets);
548
549 // Create EXTERNSHEET for each worksheet
550 for ($i = 0; $i < $countSheets; ++$i) {
551 $this->_writeExternsheet($this->_phpExcel->getSheet($i)->getTitle());
552 }
553 }
_writeExternsheet($sheetname)
Writes the Excel BIFF EXTERNSHEET record.
Definition: Workbook.php:1067
_writeExterncount($cxals)
Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in the workbook.
Definition: Workbook.php:1048

References _writeExterncount(), and _writeExternsheet().

+ Here is the call graph for this function:

◆ _writeExternsheet()

PHPExcel_Writer_Excel5_Workbook::_writeExternsheet (   $sheetname)
private

Writes the Excel BIFF EXTERNSHEET record.

These references are used by formulas. NAME record is required to define the print area and the repeat rows and columns.

A similar method is used in Worksheet.php for a slightly different purpose.

Parameters
string$sheetnameWorksheet name

Definition at line 1067 of file Workbook.php.

1068 {
1069 $record = 0x0017; // Record identifier
1070 $length = 0x02 + strlen($sheetname); // Number of bytes to follow
1071
1072 $cch = strlen($sheetname); // Length of sheet name
1073 $rgch = 0x03; // Filename encoding
1074
1075 $header = pack("vv", $record, $length);
1076 $data = pack("CC", $cch, $rgch);
1077 $this->_append($header . $data . $sheetname);
1078 }

Referenced by _writeExterns().

+ Here is the caller graph for this function:

◆ _writeExternsheetBiff8()

PHPExcel_Writer_Excel5_Workbook::_writeExternsheetBiff8 ( )
private

Writes the Excel BIFF EXTERNSHEET record.

These references are used by formulas.

Definition at line 969 of file Workbook.php.

970 {
971 $total_references = count($this->_parser->_references);
972 $record = 0x0017; // Record identifier
973 $length = 2 + 6 * $total_references; // Number of bytes to follow
974
975 $supbook_index = 0; // FIXME: only using internal SUPBOOK record
976 $header = pack("vv", $record, $length);
977 $data = pack('v', $total_references);
978 for ($i = 0; $i < $total_references; ++$i) {
979 $data .= $this->_parser->_references[$i];
980 }
981 return $this->writeData($header . $data);
982 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeMsoDrawingGroup()

PHPExcel_Writer_Excel5_Workbook::_writeMsoDrawingGroup ( )
private

Writes the MSODRAWINGGROUP record if needed.

Possibly split using CONTINUE records.

Definition at line 1413 of file Workbook.php.

1414 {
1415 // write the Escher stream if necessary
1416 if (isset($this->_escher)) {
1417 $writer = new PHPExcel_Writer_Excel5_Escher($this->_escher);
1418 $data = $writer->close();
1419
1420 $record = 0x00EB;
1421 $length = strlen($data);
1422 $header = pack("vv", $record, $length);
1423
1424 return $this->writeData($header . $data);
1425
1426 } else {
1427 return '';
1428 }
1429 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeNameLong()

PHPExcel_Writer_Excel5_Workbook::_writeNameLong (   $index,
  $type,
  $rowmin,
  $rowmax,
  $colmin,
  $colmax 
)
private

Store the NAME record in the long format that is used for storing the repeat rows and columns when both are specified.

This shares a lot of code with _writeNameShort() but we use a separate method to keep the code clean. Code abstraction for reuse can be carried too far, and I should know. ;-)

Parameters
integer$indexSheet index
integer$typeBuilt-in name type
integer$rowminStart row
integer$rowmaxEnd row
integer$colminStart colum
integer$colmaxEnd column

Definition at line 1155 of file Workbook.php.

1156 {
1157 $record = 0x0018; // Record identifier
1158 $length = 0x003d; // Number of bytes to follow
1159 $grbit = 0x0020; // Option flags
1160 $chKey = 0x00; // Keyboard shortcut
1161 $cch = 0x01; // Length of text name
1162 $cce = 0x002e; // Length of text definition
1163 $ixals = $index + 1; // Sheet index
1164 $itab = $ixals; // Equal to ixals
1165 $cchCustMenu = 0x00; // Length of cust menu text
1166 $cchDescription = 0x00; // Length of description text
1167 $cchHelptopic = 0x00; // Length of help topic text
1168 $cchStatustext = 0x00; // Length of status bar text
1169 $rgch = $type; // Built-in name type
1170
1171 $unknown01 = 0x29;
1172 $unknown02 = 0x002b;
1173 $unknown03 = 0x3b;
1174 $unknown04 = 0xffff-$index;
1175 $unknown05 = 0x0000;
1176 $unknown06 = 0x0000;
1177 $unknown07 = 0x1087;
1178 $unknown08 = 0x8008;
1179
1180 $header = pack("vv", $record, $length);
1181 $data = pack("v", $grbit);
1182 $data .= pack("C", $chKey);
1183 $data .= pack("C", $cch);
1184 $data .= pack("v", $cce);
1185 $data .= pack("v", $ixals);
1186 $data .= pack("v", $itab);
1187 $data .= pack("C", $cchCustMenu);
1188 $data .= pack("C", $cchDescription);
1189 $data .= pack("C", $cchHelptopic);
1190 $data .= pack("C", $cchStatustext);
1191 $data .= pack("C", $rgch);
1192 $data .= pack("C", $unknown01);
1193 $data .= pack("v", $unknown02);
1194 // Column definition
1195 $data .= pack("C", $unknown03);
1196 $data .= pack("v", $unknown04);
1197 $data .= pack("v", $unknown05);
1198 $data .= pack("v", $unknown06);
1199 $data .= pack("v", $unknown07);
1200 $data .= pack("v", $unknown08);
1201 $data .= pack("v", $index);
1202 $data .= pack("v", $index);
1203 $data .= pack("v", 0x0000);
1204 $data .= pack("v", 0x3fff);
1205 $data .= pack("C", $colmin);
1206 $data .= pack("C", $colmax);
1207 // Row definition
1208 $data .= pack("C", $unknown03);
1209 $data .= pack("v", $unknown04);
1210 $data .= pack("v", $unknown05);
1211 $data .= pack("v", $unknown06);
1212 $data .= pack("v", $unknown07);
1213 $data .= pack("v", $unknown08);
1214 $data .= pack("v", $index);
1215 $data .= pack("v", $index);
1216 $data .= pack("v", $rowmin);
1217 $data .= pack("v", $rowmax);
1218 $data .= pack("C", 0x00);
1219 $data .= pack("C", 0xff);
1220 // End of data
1221 $data .= pack("C", 0x10);
1222 $this->_append($header . $data);
1223 }

Referenced by _writeNames().

+ Here is the caller graph for this function:

◆ _writeNames()

PHPExcel_Writer_Excel5_Workbook::_writeNames ( )
private

Write the NAME record to define the print area and the repeat rows and cols.

Definition at line 558 of file Workbook.php.

559 {
560 // total number of sheets
561 $total_worksheets = $this->_phpExcel->getSheetCount();
562
563 // Create the print area NAME records
564 for ($i = 0; $i < $total_worksheets; ++$i) {
565 $sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup();
566 // Write a Name record if the print area has been defined
567 if ($sheetSetup->isPrintAreaSet()) {
568 // Print area
569 $printArea = PHPExcel_Cell::splitRange($sheetSetup->getPrintArea());
570 $printArea = $printArea[0];
571 $printArea[0] = PHPExcel_Cell::coordinateFromString($printArea[0]);
572 $printArea[1] = PHPExcel_Cell::coordinateFromString($printArea[1]);
573
574 $print_rowmin = $printArea[0][1] - 1;
575 $print_rowmax = $printArea[1][1] - 1;
576 $print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1;
577 $print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1;
578
579 $this->_writeNameShort(
580 $i, // sheet index
581 0x06, // NAME type
582 $print_rowmin,
583 $print_rowmax,
584 $print_colmin,
585 $print_colmax
586 );
587 }
588 }
589
590 // Create the print title NAME records
591 for ($i = 0; $i < $total_worksheets; ++$i) {
592 $sheetSetup = $this->_phpExcel->getSheet($i)->getPageSetup();
593
594 // simultaneous repeatColumns repeatRows
595 if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) {
596 $repeat = $sheetSetup->getColumnsToRepeatAtLeft();
597 $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
598 $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;
599
600 $repeat = $sheetSetup->getRowsToRepeatAtTop();
601 $rowmin = $repeat[0] - 1;
602 $rowmax = $repeat[1] - 1;
603
604 $this->_writeNameLong(
605 $i, // sheet index
606 0x07, // NAME type
607 $rowmin,
608 $rowmax,
609 $colmin,
610 $colmax
611 );
612
613 // (exclusive) either repeatColumns or repeatRows
614 } else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
615
616 // Columns to repeat
617 if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
618 $repeat = $sheetSetup->getColumnsToRepeatAtLeft();
619 $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
620 $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;
621 } else {
622 $colmin = 0;
623 $colmax = 255;
624 }
625
626 // Rows to repeat
627 if ($sheetSetup->isRowsToRepeatAtTopSet()) {
628 $repeat = $sheetSetup->getRowsToRepeatAtTop();
629 $rowmin = $repeat[0] - 1;
630 $rowmax = $repeat[1] - 1;
631 } else {
632 $rowmin = 0;
633 $rowmax = 65535;
634 }
635
636 $this->_writeNameShort(
637 $i, // sheet index
638 0x07, // NAME type
639 $rowmin,
640 $rowmax,
641 $colmin,
642 $colmax
643 );
644 }
645 }
646 }
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
Definition: Cell.php:580
static columnIndexFromString($pString='A')
Column index from string.
Definition: Cell.php:782
_writeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax)
Store the NAME record in the long format that is used for storing the repeat rows and columns when bo...
Definition: Workbook.php:1155
_writeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax)
Store the NAME record in the short format that is used for storing the print area,...
Definition: Workbook.php:1091

References _writeNameLong(), _writeNameShort(), PHPExcel_Cell\columnIndexFromString(), PHPExcel_Cell\coordinateFromString(), and PHPExcel_Cell\splitRange().

+ Here is the call graph for this function:

◆ _writeNameShort()

PHPExcel_Writer_Excel5_Workbook::_writeNameShort (   $index,
  $type,
  $rowmin,
  $rowmax,
  $colmin,
  $colmax 
)
private

Store the NAME record in the short format that is used for storing the print area, repeat rows only and repeat columns only.

Parameters
integer$indexSheet index
integer$typeBuilt-in name type
integer$rowminStart row
integer$rowmaxEnd row
integer$colminStart colum
integer$colmaxEnd column

Definition at line 1091 of file Workbook.php.

1092 {
1093 $record = 0x0018; // Record identifier
1094 $length = 0x0024; // Number of bytes to follow
1095
1096 $grbit = 0x0020; // Option flags
1097 $chKey = 0x00; // Keyboard shortcut
1098 $cch = 0x01; // Length of text name
1099 $cce = 0x0015; // Length of text definition
1100 $ixals = $index + 1; // Sheet index
1101 $itab = $ixals; // Equal to ixals
1102 $cchCustMenu = 0x00; // Length of cust menu text
1103 $cchDescription = 0x00; // Length of description text
1104 $cchHelptopic = 0x00; // Length of help topic text
1105 $cchStatustext = 0x00; // Length of status bar text
1106 $rgch = $type; // Built-in name type
1107
1108 $unknown03 = 0x3b;
1109 $unknown04 = 0xffff-$index;
1110 $unknown05 = 0x0000;
1111 $unknown06 = 0x0000;
1112 $unknown07 = 0x1087;
1113 $unknown08 = 0x8005;
1114
1115 $header = pack("vv", $record, $length);
1116 $data = pack("v", $grbit);
1117 $data .= pack("C", $chKey);
1118 $data .= pack("C", $cch);
1119 $data .= pack("v", $cce);
1120 $data .= pack("v", $ixals);
1121 $data .= pack("v", $itab);
1122 $data .= pack("C", $cchCustMenu);
1123 $data .= pack("C", $cchDescription);
1124 $data .= pack("C", $cchHelptopic);
1125 $data .= pack("C", $cchStatustext);
1126 $data .= pack("C", $rgch);
1127 $data .= pack("C", $unknown03);
1128 $data .= pack("v", $unknown04);
1129 $data .= pack("v", $unknown05);
1130 $data .= pack("v", $unknown06);
1131 $data .= pack("v", $unknown07);
1132 $data .= pack("v", $unknown08);
1133 $data .= pack("v", $index);
1134 $data .= pack("v", $index);
1135 $data .= pack("v", $rowmin);
1136 $data .= pack("v", $rowmax);
1137 $data .= pack("C", $colmin);
1138 $data .= pack("C", $colmax);
1139 $this->_append($header . $data);
1140 }

Referenced by _writeNames().

+ Here is the caller graph for this function:

◆ _writeNumFormat()

PHPExcel_Writer_Excel5_Workbook::_writeNumFormat (   $format,
  $ifmt 
)
private

Writes Excel FORMAT record for non "built-in" numerical formats.

Parameters
string$formatCustom format string
integer$ifmtFormat index code

Definition at line 1007 of file Workbook.php.

1008 {
1009 $record = 0x041E; // Record identifier
1010
1011 $numberFormatString = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($format);
1012 $length = 2 + strlen($numberFormatString); // Number of bytes to follow
1013
1014
1015 $header = pack("vv", $record, $length);
1016 $data = pack("v", $ifmt) . $numberFormatString;
1017 $this->_append($header . $data);
1018 }

Referenced by _writeAllNumFormats().

+ Here is the caller graph for this function:

◆ _writePalette()

PHPExcel_Writer_Excel5_Workbook::_writePalette ( )
private

Stores the PALETTE biff record.

Definition at line 1263 of file Workbook.php.

1264 {
1265 $aref = $this->_palette;
1266
1267 $record = 0x0092; // Record identifier
1268 $length = 2 + 4 * count($aref); // Number of bytes to follow
1269 $ccv = count($aref); // Number of RGB values to follow
1270 $data = ''; // The RGB data
1271
1272 // Pack the RGB data
1273 foreach ($aref as $color) {
1274 foreach ($color as $byte) {
1275 $data .= pack("C",$byte);
1276 }
1277 }
1278
1279 $header = pack("vvv", $record, $length, $ccv);
1280 $this->_append($header . $data);
1281 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeRecalcId()

PHPExcel_Writer_Excel5_Workbook::_writeRecalcId ( )
private

Write the RECALCID record.

Returns
string

Definition at line 1247 of file Workbook.php.

1248 {
1249 $record = 0x01C1; // Record identifier
1250 $length = 8; // Number of bytes to follow
1251
1252 $header = pack('vv', $record, $length);
1253
1254 // by inspection of real Excel files, MS Office Excel 2007 writes this
1255 $data = pack('VV', 0x000001C1, 0x00001E667);
1256
1257 return $this->writeData($header . $data);
1258 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeSharedStringsTable()

PHPExcel_Writer_Excel5_Workbook::_writeSharedStringsTable ( )
private

Handling of the SST continue blocks is complicated by the need to include an additional continuation byte depending on whether the string is split between blocks or whether it starts at the beginning of the block.

(There are also additional complications that will arise later when/if Rich Strings are supported).

The Excel documentation says that the SST record should be followed by an EXTSST record. The EXTSST record is a hash table that is used to optimise access to SST. However, despite the documentation it doesn't seem to be required so we will ignore it.

Returns
string Binary data

Definition at line 1297 of file Workbook.php.

1298 {
1299 // maximum size of record data (excluding record header)
1300 $continue_limit = 8224;
1301
1302 // initialize array of record data blocks
1303 $recordDatas = array();
1304
1305 // start SST record data block with total number of strings, total number of unique strings
1306 $recordData = pack("VV", $this->_str_total, $this->_str_unique);
1307
1308 // loop through all (unique) strings in shared strings table
1309 foreach (array_keys($this->_str_table) as $string) {
1310
1311 // here $string is a BIFF8 encoded string
1312
1313 // length = character count
1314 $headerinfo = unpack("vlength/Cencoding", $string);
1315
1316 // currently, this is always 1 = uncompressed
1317 $encoding = $headerinfo["encoding"];
1318
1319 // initialize finished writing current $string
1320 $finished = false;
1321
1322 while ($finished === false) {
1323
1324 // normally, there will be only one cycle, but if string cannot immediately be written as is
1325 // there will be need for more than one cylcle, if string longer than one record data block, there
1326 // may be need for even more cycles
1327
1328 if (strlen($recordData) + strlen($string) <= $continue_limit) {
1329 // then we can write the string (or remainder of string) without any problems
1330 $recordData .= $string;
1331
1332 if (strlen($recordData) + strlen($string) == $continue_limit) {
1333 // we close the record data block, and initialize a new one
1334 $recordDatas[] = $recordData;
1335 $recordData = '';
1336 }
1337
1338 // we are finished writing this string
1339 $finished = true;
1340 } else {
1341 // special treatment writing the string (or remainder of the string)
1342 // If the string is very long it may need to be written in more than one CONTINUE record.
1343
1344 // check how many bytes more there is room for in the current record
1345 $space_remaining = $continue_limit - strlen($recordData);
1346
1347 // minimum space needed
1348 // uncompressed: 2 byte string length length field + 1 byte option flags + 2 byte character
1349 // compressed: 2 byte string length length field + 1 byte option flags + 1 byte character
1350 $min_space_needed = ($encoding == 1) ? 5 : 4;
1351
1352 // We have two cases
1353 // 1. space remaining is less than minimum space needed
1354 // here we must waste the space remaining and move to next record data block
1355 // 2. space remaining is greater than or equal to minimum space needed
1356 // here we write as much as we can in the current block, then move to next record data block
1357
1358 // 1. space remaining is less than minimum space needed
1359 if ($space_remaining < $min_space_needed) {
1360 // we close the block, store the block data
1361 $recordDatas[] = $recordData;
1362
1363 // and start new record data block where we start writing the string
1364 $recordData = '';
1365
1366 // 2. space remaining is greater than or equal to minimum space needed
1367 } else {
1368 // initialize effective remaining space, for Unicode strings this may need to be reduced by 1, see below
1369 $effective_space_remaining = $space_remaining;
1370
1371 // for uncompressed strings, sometimes effective space remaining is reduced by 1
1372 if ( $encoding == 1 && (strlen($string) - $space_remaining) % 2 == 1 ) {
1373 --$effective_space_remaining;
1374 }
1375
1376 // one block fininshed, store the block data
1377 $recordData .= substr($string, 0, $effective_space_remaining);
1378
1379 $string = substr($string, $effective_space_remaining); // for next cycle in while loop
1380 $recordDatas[] = $recordData;
1381
1382 // start new record data block with the repeated option flags
1383 $recordData = pack('C', $encoding);
1384 }
1385 }
1386 }
1387 }
1388
1389 // Store the last record data block unless it is empty
1390 // if there was no need for any continue records, this will be the for SST record data block itself
1391 if (strlen($recordData) > 0) {
1392 $recordDatas[] = $recordData;
1393 }
1394
1395 // combine into one chunk with all the blocks SST, CONTINUE,...
1396 $chunk = '';
1397 foreach ($recordDatas as $i => $recordData) {
1398 // first block should have the SST record header, remaing should have CONTINUE header
1399 $record = ($i == 0) ? 0x00FC : 0x003C;
1400
1401 $header = pack("vv", $record, strlen($recordData));
1402 $data = $header . $recordData;
1403
1404 $chunk .= $this->writeData($data);
1405 }
1406
1407 return $chunk;
1408 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeShortNameBiff8()

PHPExcel_Writer_Excel5_Workbook::_writeShortNameBiff8 (   $name,
  $sheetIndex = 0,
  $rangeBounds,
  $isHidden = false 
)
private

Write a short NAME record.

Parameters
string$name
string$sheetIndex1-based sheet index the defined name applies to. 0 = global
integer[][]$rangeBoundsrange boundaries
boolean$isHidden
Returns
string Complete binary record data

Definition at line 845 of file Workbook.php.

845 {
846 $record = 0x0018;
847
848 // option flags
849 $options = ($isHidden ? 0x21 : 0x00);
850
851 $extra = pack('Cvvvvv',
852 0x3B,
853 $sheetIndex - 1,
854 $rangeBounds[0][1] - 1,
855 $rangeBounds[1][1] - 1,
856 $rangeBounds[0][0] - 1,
857 $rangeBounds[1][0] - 1);
858
859 // size of the formula (in bytes)
860 $sz = strlen($extra);
861
862 // combine the parts
863 $data = pack('vCCvvvCCCCC', $options, 0, 1, $sz, 0, $sheetIndex, 0, 0, 0, 0, 0)
864 . $name . $extra;
865 $length = strlen($data);
866
867 $header = pack('vv', $record, $length);
868
869 return $header . $data;
870 }

◆ _writeStyle()

PHPExcel_Writer_Excel5_Workbook::_writeStyle ( )
private

Write Excel BIFF STYLE records.

Definition at line 987 of file Workbook.php.

988 {
989 $record = 0x0293; // Record identifier
990 $length = 0x0004; // Bytes to follow
991
992 $ixfe = 0x8000; // Index to cell style XF
993 $BuiltIn = 0x00; // Built-in style
994 $iLevel = 0xff; // Outline style level
995
996 $header = pack("vv", $record, $length);
997 $data = pack("vCC", $ixfe, $BuiltIn, $iLevel);
998 $this->_append($header . $data);
999 }

Referenced by _writeAllStyles().

+ Here is the caller graph for this function:

◆ _writeSupbookInternal()

PHPExcel_Writer_Excel5_Workbook::_writeSupbookInternal ( )
private

Write Internal SUPBOOK record.

Definition at line 954 of file Workbook.php.

955 {
956 $record = 0x01AE; // Record identifier
957 $length = 0x0004; // Bytes to follow
958
959 $header = pack("vv", $record, $length);
960 $data = pack("vv", $this->_phpExcel->getSheetCount(), 0x0401);
961 return $this->writeData($header . $data);
962 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ _writeWindow1()

PHPExcel_Writer_Excel5_Workbook::_writeWindow1 ( )
private

Write Excel BIFF WINDOW1 record.

Definition at line 890 of file Workbook.php.

891 {
892 $record = 0x003D; // Record identifier
893 $length = 0x0012; // Number of bytes to follow
894
895 $xWn = 0x0000; // Horizontal position of window
896 $yWn = 0x0000; // Vertical position of window
897 $dxWn = 0x25BC; // Width of window
898 $dyWn = 0x1572; // Height of window
899
900 $grbit = 0x0038; // Option flags
901
902 // not supported by PHPExcel, so there is only one selected sheet, the active
903 $ctabsel = 1; // Number of workbook tabs selected
904
905 $wTabRatio = 0x0258; // Tab to scrollbar ratio
906
907 // not supported by PHPExcel, set to 0
908 $itabFirst = 0; // 1st displayed worksheet
909 $itabCur = $this->_phpExcel->getActiveSheetIndex(); // Active worksheet
910
911 $header = pack("vv", $record, $length);
912 $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn,
913 $grbit,
914 $itabCur, $itabFirst,
915 $ctabsel, $wTabRatio);
916 $this->_append($header . $data);
917 }

Referenced by writeWorkbook().

+ Here is the caller graph for this function:

◆ addXfWriter()

PHPExcel_Writer_Excel5_Workbook::addXfWriter (   $style,
  $isStyleXf = false 
)

Add a new XF writer.

Parameters
PHPExcel_Style
booleanIs it a style XF?
Returns
int Index to XF record

Definition at line 253 of file Workbook.php.

254 {
255 $xfWriter = new PHPExcel_Writer_Excel5_Xf($style);
256 $xfWriter->setIsStyleXf($isStyleXf);
257
258 // Add the font if not already added
259 $fontIndex = $this->_addFont($style->getFont());
260
261 // Assign the font index to the xf record
262 $xfWriter->setFontIndex($fontIndex);
263
264 // Background colors, best to treat these after the font so black will come after white in custom palette
265 $xfWriter->setFgColor($this->_addColor($style->getFill()->getStartColor()->getRGB()));
266 $xfWriter->setBgColor($this->_addColor($style->getFill()->getEndColor()->getRGB()));
267 $xfWriter->setBottomColor($this->_addColor($style->getBorders()->getBottom()->getColor()->getRGB()));
268 $xfWriter->setTopColor($this->_addColor($style->getBorders()->getTop()->getColor()->getRGB()));
269 $xfWriter->setRightColor($this->_addColor($style->getBorders()->getRight()->getColor()->getRGB()));
270 $xfWriter->setLeftColor($this->_addColor($style->getBorders()->getLeft()->getColor()->getRGB()));
271 $xfWriter->setDiagColor($this->_addColor($style->getBorders()->getDiagonal()->getColor()->getRGB()));
272
273 // Add the number format if it is not a built-in one and not already added
274 if ($style->getNumberFormat()->getBuiltInFormatCode() === false) {
275 $numberFormatHashCode = $style->getNumberFormat()->getHashCode();
276
277 if (isset($this->_addedNumberFormats[$numberFormatHashCode])) {
278 $numberFormatIndex = $this->_addedNumberFormats[$numberFormatHashCode];
279 } else {
280 $numberFormatIndex = 164 + count($this->_numberFormats);
281 $this->_numberFormats[$numberFormatIndex] = $style->getNumberFormat();
282 $this->_addedNumberFormats[$numberFormatHashCode] = $numberFormatIndex;
283 }
284 } else {
285 $numberFormatIndex = (int) $style->getNumberFormat()->getBuiltInFormatCode();
286 }
287
288 // Assign the number format index to xf record
289 $xfWriter->setNumberFormatIndex($numberFormatIndex);
290
291 $this->_xfWriters[] = $xfWriter;
292
293 $xfIndex = count($this->_xfWriters) - 1;
294 return $xfIndex;
295 }
_addFont(PHPExcel_Style_Font $font)
Add a font to added fonts.
Definition: Workbook.php:303
$style
Definition: example_012.php:70

References $style, _addColor(), and _addFont().

+ Here is the call graph for this function:

◆ getEscher()

PHPExcel_Writer_Excel5_Workbook::getEscher ( )

Get Escher object.

Returns
PHPExcel_Shared_Escher

Definition at line 1436 of file Workbook.php.

1437 {
1438 return $this->_escher;
1439 }

◆ setEscher()

PHPExcel_Writer_Excel5_Workbook::setEscher ( PHPExcel_Shared_Escher  $pValue = null)

Set Escher object.

Parameters
PHPExcel_Shared_Escher$pValue

Definition at line 1446 of file Workbook.php.

1447 {
1448 $this->_escher = $pValue;
1449 }

◆ writeWorkbook()

PHPExcel_Writer_Excel5_Workbook::writeWorkbook (   $pWorksheetSizes = null)

Assemble worksheets into a workbook and send the BIFF data to an OLE storage.

Parameters
array$pWorksheetSizesThe sizes in bytes of the binary worksheet streams
Returns
string Binary data for workbook stream

Definition at line 426 of file Workbook.php.

427 {
428 $this->_worksheetSizes = $pWorksheetSizes;
429
430 // Calculate the number of selected worksheet tabs and call the finalization
431 // methods for each worksheet
432 $total_worksheets = $this->_phpExcel->getSheetCount();
433
434 // Add part 1 of the Workbook globals, what goes before the SHEET records
435 $this->_storeBof(0x0005);
436 $this->_writeCodepage();
437 $this->_writeWindow1();
438
439 $this->_writeDatemode();
440 $this->_writeAllFonts();
441 $this->_writeAllNumFormats();
442 $this->_writeAllXfs();
443 $this->_writeAllStyles();
444 $this->_writePalette();
445
446 // Prepare part 3 of the workbook global stream, what goes after the SHEET records
447 $part3 = '';
448 if ($this->_country_code != -1) {
449 $part3 .= $this->_writeCountry();
450 }
451 $part3 .= $this->_writeRecalcId();
452
453 $part3 .= $this->_writeSupbookInternal();
454 /* TODO: store external SUPBOOK records and XCT and CRN records
455 in case of external references for BIFF8 */
456 $part3 .= $this->_writeExternsheetBiff8();
457 $part3 .= $this->_writeAllDefinedNamesBiff8();
458 $part3 .= $this->_writeMsoDrawingGroup();
459 $part3 .= $this->_writeSharedStringsTable();
460
461 $part3 .= $this->writeEof();
462
463 // Add part 2 of the Workbook globals, the SHEET records
464 $this->_calcSheetOffsets();
465 for ($i = 0; $i < $total_worksheets; ++$i) {
466 $this->_writeBoundsheet($this->_phpExcel->getSheet($i), $this->_worksheetOffsets[$i]);
467 }
468
469 // Add part 3 of the Workbook globals
470 $this->_data .= $part3;
471
472 return $this->_data;
473 }
_storeBof($type)
Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file.
Definition: BIFFwriter.php:172
writeEof()
Writes Excel EOF record to indicate the end of a BIFF stream.
Definition: BIFFwriter.php:209
_writeRecalcId()
Write the RECALCID record.
Definition: Workbook.php:1247
_writeExternsheetBiff8()
Writes the Excel BIFF EXTERNSHEET record.
Definition: Workbook.php:969
_writeSharedStringsTable()
Handling of the SST continue blocks is complicated by the need to include an additional continuation ...
Definition: Workbook.php:1297
_writeBoundsheet($sheet, $offset)
Writes Excel BIFF BOUNDSHEET record.
Definition: Workbook.php:925
_writeCountry()
Stores the COUNTRY record for localization.
Definition: Workbook.php:1230
_writeMsoDrawingGroup()
Writes the MSODRAWINGGROUP record if needed.
Definition: Workbook.php:1413
_calcSheetOffsets()
Calculate offsets for Worksheet BOF records.
Definition: Workbook.php:480
_writeCodepage()
Stores the CODEPAGE biff record.
Definition: Workbook.php:875
_writePalette()
Stores the PALETTE biff record.
Definition: Workbook.php:1263
_writeAllFonts()
Store the Excel FONT records.
Definition: Workbook.php:504
_writeAllXfs()
Write all XF records.
Definition: Workbook.php:524
_writeSupbookInternal()
Write Internal SUPBOOK record.
Definition: Workbook.php:954
_writeDatemode()
Write DATEMODE record to indicate the date system in use (1904 or 1900).
Definition: Workbook.php:1023
_writeAllDefinedNamesBiff8()
Writes all the DEFINEDNAME records (BIFF8).
Definition: Workbook.php:652
_writeWindow1()
Write Excel BIFF WINDOW1 record.
Definition: Workbook.php:890
_writeAllStyles()
Write all STYLE records.
Definition: Workbook.php:534
_writeAllNumFormats()
Store user defined numerical formats i.e.
Definition: Workbook.php:514

References PHPExcel_Writer_Excel5_BIFFwriter\$_data, _calcSheetOffsets(), PHPExcel_Writer_Excel5_BIFFwriter\_storeBof(), _writeAllDefinedNamesBiff8(), _writeAllFonts(), _writeAllNumFormats(), _writeAllStyles(), _writeAllXfs(), _writeBoundsheet(), _writeCodepage(), _writeCountry(), _writeDatemode(), _writeExternsheetBiff8(), _writeMsoDrawingGroup(), _writePalette(), _writeRecalcId(), _writeSharedStringsTable(), _writeSupbookInternal(), _writeWindow1(), and PHPExcel_Writer_Excel5_BIFFwriter\writeEof().

+ Here is the call graph for this function:

Field Documentation

◆ $_addedFonts

PHPExcel_Writer_Excel5_Workbook::$_addedFonts = array()
private

Definition at line 129 of file Workbook.php.

◆ $_addedNumberFormats

PHPExcel_Writer_Excel5_Workbook::$_addedNumberFormats = array()
private

Definition at line 143 of file Workbook.php.

◆ $_biffsize

PHPExcel_Writer_Excel5_Workbook::$_biffsize

Definition at line 85 of file Workbook.php.

◆ $_codepage

PHPExcel_Writer_Excel5_Workbook::$_codepage

Definition at line 103 of file Workbook.php.

◆ $_colors

PHPExcel_Writer_Excel5_Workbook::$_colors
private

Color cache.

Definition at line 183 of file Workbook.php.

◆ $_country_code

PHPExcel_Writer_Excel5_Workbook::$_country_code

Definition at line 109 of file Workbook.php.

◆ $_escher

PHPExcel_Writer_Excel5_Workbook::$_escher
private

Definition at line 190 of file Workbook.php.

◆ $_fontWriters

PHPExcel_Writer_Excel5_Workbook::$_fontWriters = array()
private

Definition at line 122 of file Workbook.php.

◆ $_numberFormats

PHPExcel_Writer_Excel5_Workbook::$_numberFormats = array()
private

Definition at line 136 of file Workbook.php.

◆ $_palette

PHPExcel_Writer_Excel5_Workbook::$_palette

Definition at line 97 of file Workbook.php.

◆ $_parser

PHPExcel_Writer_Excel5_Workbook::$_parser
private

Definition at line 78 of file Workbook.php.

◆ $_phpExcel

PHPExcel_Writer_Excel5_Workbook::$_phpExcel
private

Definition at line 115 of file Workbook.php.

◆ $_str_table

PHPExcel_Writer_Excel5_Workbook::$_str_table
private

Definition at line 178 of file Workbook.php.

◆ $_str_total

PHPExcel_Writer_Excel5_Workbook::$_str_total
private

Definition at line 164 of file Workbook.php.

◆ $_str_unique

PHPExcel_Writer_Excel5_Workbook::$_str_unique
private

Definition at line 171 of file Workbook.php.

◆ $_worksheetOffsets

PHPExcel_Writer_Excel5_Workbook::$_worksheetOffsets = array()
private

Definition at line 157 of file Workbook.php.

◆ $_worksheetSizes

PHPExcel_Writer_Excel5_Workbook::$_worksheetSizes = array()
private

Definition at line 150 of file Workbook.php.

◆ $_xfWriters

PHPExcel_Writer_Excel5_Workbook::$_xfWriters = array()
private

Definition at line 91 of file Workbook.php.


The documentation for this class was generated from the following file: