226        parent::__construct();
 
  229        $this->stringTotal = &$str_total;
 
  230        $this->stringUnique = &$str_unique;
 
  231        $this->stringTable = &$str_table;
 
  237        $this->xlsStringMaxLength = 255;
 
  238        $this->columnInfo = [];
 
  239        $this->selection = [0, 0, 0, 0];
 
  240        $this->activePane = 3;
 
  242        $this->printHeaders = 0;
 
  244        $this->outlineStyle = 
false;
 
  245        $this->outlineBelow = 
true;
 
  246        $this->outlineRight = 
true;
 
  247        $this->outlineOn = 
true;
 
  249        $this->fontHashIndex = [];
 
  255        $maxR = $this->phpSheet->getHighestRow();
 
  256        $maxC = $this->phpSheet->getHighestColumn();
 
  259        $this->firstRowIndex = $minR;
 
  260        $this->lastRowIndex = ($maxR > 65535) ? 65535 : $maxR;
 
  265        if ($this->lastColumnIndex > 255) {
 
  266            $this->lastColumnIndex = 255;
 
  269        $this->countCellStyleXfs = count(
$phpSheet->getParent()->getCellStyleXfCollection());
 
  278    public function close(): void
 
  283        $selectedCells = $this->phpSheet->getSelectedCells();
 
  284        $activeSheetIndex = $this->phpSheet->getParent()->getActiveSheetIndex();
 
  302        if (($defaultWidth = 
$phpSheet->getDefaultColumnDimension()->getWidth()) < 0) {
 
  306        $columnDimensions = 
$phpSheet->getColumnDimensions();
 
  307        $maxCol = $this->lastColumnIndex - 1;
 
  308        for (
$i = 0; 
$i <= $maxCol; ++
$i) {
 
  313            $width = $defaultWidth;
 
  316            if (isset($columnDimensions[$columnLetter])) {
 
  317                $columnDimension = $columnDimensions[$columnLetter];
 
  318                if ($columnDimension->getWidth() >= 0) {
 
  319                    $width = $columnDimension->getWidth();
 
  321                $hidden = $columnDimension->getVisible() ? 0 : 1;
 
  322                $level = $columnDimension->getOutlineLevel();
 
  323                $xfIndex = $columnDimension->getXfIndex() + 15; 
 
  333            $this->columnInfo[] = [
$i, 
$i, $width, $xfIndex, $hidden, $level];
 
  375        if (!empty($this->columnInfo)) {
 
  376            $colcount = count($this->columnInfo);
 
  377            for (
$i = 0; 
$i < $colcount; ++
$i) {
 
  381        $autoFilterRange = 
$phpSheet->getAutoFilter()->getRange();
 
  382        if (!empty($autoFilterRange)) {
 
  391        foreach (
$phpSheet->getRowDimensions() as $rowDimension) {
 
  392            $xfIndex = $rowDimension->getXfIndex() + 15; 
 
  394                $rowDimension->getRowIndex() - 1,
 
  395                (
int) $rowDimension->getRowHeight(),
 
  397                !$rowDimension->getVisible(),
 
  398                $rowDimension->getOutlineLevel()
 
  403        foreach (
$phpSheet->getCoordinates() as $coordinate) {
 
  405            $row = $cell->getRow() - 1;
 
  409            if (
$row > 65535 || $column > 255) {
 
  410                throw new WriterException(
'Rows or columns overflow! Excel5 has limit to 65535 rows and 255 columns. Use XLSX instead.');
 
  414            $xfIndex = $cell->getXfIndex() + 15; 
 
  416            $cVal = $cell->getValue();
 
  417            if ($cVal instanceof RichText) {
 
  420                $elements = $cVal->getRichTextElements();
 
  421                foreach ($elements as $element) {
 
  423                    if ($element instanceof Run) {
 
  424                        $str_fontidx = $this->fontHashIndex[$element->getFont()->getHashCode()];
 
  428                    $arrcRun[] = [
'strlen' => $str_pos, 
'fontidx' => $str_fontidx];
 
  434                switch ($cell->getDatatype()) {
 
  437                        if ($cVal === 
'' || $cVal === 
null) {
 
  449                        $calculatedValue = $this->preCalculateFormulas ?
 
  450                            $cell->getCalculatedValue() : 
null;
 
  451                        if (self::WRITE_FORMULA_EXCEPTION == $this->
writeFormula(
$row, $column, $cVal, $xfIndex, $calculatedValue)) {
 
  452                            if ($calculatedValue === 
null) {
 
  453                                $calculatedValue = $cell->getCalculatedValue();
 
  455                            $calctype = gettype($calculatedValue);
 
  492        $this->phpSheet->getParent()->setActiveSheetIndex($activeSheetIndex);
 
  507        $this->phpSheet->setSelectedCells($selectedCells);
 
  516        foreach (
$phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
 
  519            $url = $hyperlink->getUrl();
 
  521            if (strpos(
$url, 
'sheet://') !== 
false) {
 
  523                $url = str_replace(
'sheet://', 
'internal:', 
$url);
 
  524            } elseif (preg_match(
'/^(http:|https:|ftp:|mailto:)/', 
$url)) {
 
  541        $arrConditionalStyles = 
$phpSheet->getConditionalStylesCollection();
 
  542        if (!empty($arrConditionalStyles)) {
 
  543            $arrConditional = [];
 
  545            $cfHeaderWritten = 
false;
 
  547            foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) {
 
  548                foreach ($conditionalStyles as $conditional) {
 
  555                        if ($cfHeaderWritten === 
false) {
 
  557                            $cfHeaderWritten = 
true;
 
  559                        if (!isset($arrConditional[$conditional->getHashCode()])) {
 
  561                            $arrConditional[$conditional->getHashCode()] = 
true;
 
  585        $explodes = explode(
':', $range);
 
  588        $firstCell = $explodes[0];
 
  591        if (count($explodes) == 1) {
 
  592            $lastCell = $firstCell;
 
  594            $lastCell = $explodes[1];
 
  600        return pack(
'vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, $firstCellCoordinates[0] - 1, $lastCellCoordinates[0] - 1);
 
  612        if (isset($this->_data)) {
 
  630        $this->printHeaders = $print;
 
  642    public function setOutline($visible = 
true, $symbols_below = 
true, $symbols_right = 
true, $auto_style = 
false): void
 
  644        $this->outlineOn = $visible;
 
  645        $this->outlineBelow = $symbols_below;
 
  646        $this->outlineRight = $symbols_right;
 
  647        $this->outlineStyle = $auto_style;
 
  671        $data = pack(
'vvv', 
$row, $col, $xfIndex);
 
  672        $xl_double = pack(
'd', $num);
 
  673        if (self::getByteOrder()) { 
 
  674            $xl_double = strrev($xl_double);
 
  712        if (!isset($this->stringTable[$str])) {
 
  713            $this->stringTable[$str] = $this->stringUnique++;
 
  718        $data = pack(
'vvvV', 
$row, $col, $xfIndex, $this->stringTable[$str]);
 
  740        if (!isset($this->stringTable[$str])) {
 
  741            $this->stringTable[$str] = $this->stringUnique++;
 
  746        $data = pack(
'vvvV', 
$row, $col, $xfIndex, $this->stringTable[$str]);
 
  774        $data = pack(
'vvv', 
$row, $col, $xfIndex);
 
  797        $data = pack(
'vvvCC', 
$row, $col, $xfIndex, $value, $isError);
 
  833        if (isset($calculatedValue)) {
 
  836            if (is_bool($calculatedValue)) {
 
  838                $num = pack(
'CCCvCv', 0x01, 0x00, (
int) $calculatedValue, 0x00, 0x00, 0xFFFF);
 
  839            } elseif (is_int($calculatedValue) || is_float($calculatedValue)) {
 
  841                $num = pack(
'd', $calculatedValue);
 
  842            } elseif (is_string($calculatedValue)) {
 
  844                if (isset($errorCodes[$calculatedValue])) {
 
  846                    $num = pack(
'CCCvCv', 0x02, 0x00, 
ErrorCode::error($calculatedValue), 0x00, 0x00, 0xFFFF);
 
  847                } elseif ($calculatedValue === 
'') {
 
  849                    $num = pack(
'CCCvCv', 0x03, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
 
  852                    $stringValue = $calculatedValue;
 
  853                    $num = pack(
'CCCvCv', 0x00, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
 
  857                $num = pack(
'd', 0x00);
 
  860            $num = pack(
'd', 0x00);
 
  867        if ($formula[0] == 
'=') {
 
  868            $formula = substr($formula, 1);
 
  871            $this->
writeString(
$row, $col, 
'Unrecognised character for formula', 0);
 
  878            $this->parser->parse($formula);
 
  879            $formula = $this->parser->toReversePolish();
 
  881            $formlen = strlen($formula); 
 
  886            $data = pack(
'vvv', 
$row, $col, $xfIndex)
 
  888                . pack(
'vVv', $grbit, $unknown, $formlen);
 
  892            if ($stringValue !== 
null) {
 
  897        } 
catch (PhpSpreadsheetException $e) {
 
  956        if (preg_match(
'[^internal:]', 
$url)) {
 
  959        if (preg_match(
'[^external:]', 
$url)) {
 
  984        $unknown1 = pack(
'H*', 
'D0C9EA79F9BACE118C8200AA004BA90B02000000');
 
  985        $unknown2 = pack(
'H*', 
'E0C9EA79F9BACE118C8200AA004BA90B');
 
  991        $url = implode(
"\0", preg_split(
"''", 
$url, -1, PREG_SPLIT_NO_EMPTY));
 
  995        $url_len = pack(
'V', strlen(
$url));
 
 1002        $data = pack(
'vvvv', $row1, $row2, $col1, $col2);
 
 1024        $url = preg_replace(
'/^internal:/', 
'', 
$url);
 
 1027        $unknown1 = pack(
'H*', 
'D0C9EA79F9BACE118C8200AA004BA90B02000000');
 
 1037        $url_len = pack(
'V', $url_len);
 
 1046        $data = pack(
'vvvv', $row1, $row2, $col1, $col2);
 
 1081        $url = preg_replace(
'/\//', 
'\\', 
$url);
 
 1089        if (preg_match(
'/^[A-Z]:/', 
$url)) {
 
 1098        if (preg_match(
'/\\#/', 
$url)) {
 
 1121        $unknown1 = pack(
'H*', 
'D0C9EA79F9BACE118C8200AA004BA90B02000000');
 
 1123        $unknown3 = pack(
'H*', 
'FFFFADDE000000000000000000000000000000000000000');
 
 1127        $data = pack(
'vvvv', $row1, $row2, $col1, $col2) .
 
 1160    private function writeRow(
$row, $height, $xfIndex, $hidden = 
false, $level = 0): void
 
 1177        if ($height !== 
null) {
 
 1178            $miyRw = $height * 20; 
 
 1190        if ($hidden === 
true) {
 
 1193        if ($height !== 
null) {
 
 1196        if ($xfIndex !== 0xF) {
 
 1201        $header = pack(
'vv', $record, $length);
 
 1202        $data = pack(
'vvvvvvvv', 
$row, $colMic, $colMac, $miyRw, $irwMac, $reserved, $grbit, $ixfe);
 
 1214        $data = pack(
'VVvvv', $this->firstRowIndex, $this->lastRowIndex + 1, $this->firstColumnIndex, $this->lastColumnIndex + 1, 0x0000); 
 
 1216        $header = pack(
'vv', $record, $length);
 
 1234        $fDspGrid = $this->phpSheet->getShowGridlines() ? 1 : 0; 
 
 1235        $fDspRwCol = $this->phpSheet->getShowRowColHeaders() ? 1 : 0; 
 
 1236        $fFrozen = $this->phpSheet->getFreezePane() ? 1 : 0; 
 
 1239        $fArabic = $this->phpSheet->getRightToLeft() ? 1 : 0; 
 
 1240        $fDspGuts = $this->outlineOn; 
 
 1241        $fFrozenNoSplit = 0; 
 
 1243        $fSelected = ($this->phpSheet === $this->phpSheet->getParent()->getActiveSheet()) ? 1 : 0;
 
 1247        $grbit |= $fDspGrid << 1;
 
 1248        $grbit |= $fDspRwCol << 2;
 
 1249        $grbit |= $fFrozen << 3;
 
 1250        $grbit |= $fDspZeros << 4;
 
 1251        $grbit |= $fDefaultHdr << 5;
 
 1252        $grbit |= $fArabic << 6;
 
 1253        $grbit |= $fDspGuts << 7;
 
 1254        $grbit |= $fFrozenNoSplit << 8;
 
 1255        $grbit |= $fSelected << 9; 
 
 1256        $grbit |= $fSelected << 10; 
 
 1257        $grbit |= $fPageBreakPreview << 11;
 
 1259        $header = pack(
'vv', $record, $length);
 
 1260        $data = pack(
'vvv', $grbit, $rwTop, $colLeft);
 
 1264        $zoom_factor_page_break = ($fPageBreakPreview ? $this->phpSheet->getSheetView()->getZoomScale() : 0x0000);
 
 1265        $zoom_factor_normal = $this->phpSheet->getSheetView()->getZoomScaleNormal();
 
 1267        $data .= pack(
'vvvvV', $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000);
 
 1277        $defaultRowHeight = $this->phpSheet->getDefaultRowDimension()->getRowHeight();
 
 1279        if ($defaultRowHeight < 0) {
 
 1284        $defaultRowHeight = (int) 20 * $defaultRowHeight;
 
 1289        $header = pack(
'vv', $record, $length);
 
 1290        $data = pack(
'vv', 1, $defaultRowHeight);
 
 1299        $defaultColWidth = 8;
 
 1304        $header = pack(
'vv', $record, $length);
 
 1305        $data = pack(
'v', $defaultColWidth);
 
 1325        $colFirst = $col_array[0] ?? 
null;
 
 1326        $colLast = $col_array[1] ?? 
null;
 
 1327        $coldx = $col_array[2] ?? 8.43;
 
 1328        $xfIndex = $col_array[3] ?? 15;
 
 1329        $grbit = $col_array[4] ?? 0;
 
 1330        $level = $col_array[5] ?? 0;
 
 1340        $level = max(0, min($level, 7));
 
 1341        $grbit |= $level << 8;
 
 1343        $header = pack(
'vv', $record, $length);
 
 1344        $data = pack(
'vvvvvv', $colFirst, $colLast, $coldx, $ixfe, $grbit, $reserved);
 
 1355        $selectedCells = $selectedCells[0];
 
 1356        if (count($selectedCells) == 2) {
 
 1357            [$first, $last] = $selectedCells;
 
 1359            $first = $selectedCells[0];
 
 1360            $last = $selectedCells[0];
 
 1372        $colFirst = min($colFirst, 255);
 
 1373        $colLast = min($colLast, 255);
 
 1375        $rwFirst = min($rwFirst, 65535);
 
 1376        $rwLast = min($rwLast, 65535);
 
 1381        $pnn = $this->activePane; 
 
 1383        $colAct = $colFirst; 
 
 1388        if ($rwFirst > $rwLast) {
 
 1389            [$rwFirst, $rwLast] = [$rwLast, $rwFirst];
 
 1392        if ($colFirst > $colLast) {
 
 1393            [$colFirst, $colLast] = [$colLast, $colFirst];
 
 1396        $header = pack(
'vv', $record, $length);
 
 1397        $data = pack(
'CvvvvvvCC', $pnn, $rwAct, $colAct, $irefAct, $cref, $rwFirst, $rwLast, $colFirst, $colLast);
 
 1406        $mergeCells = $this->phpSheet->getMergeCells();
 
 1407        $countMergeCells = count($mergeCells);
 
 1409        if ($countMergeCells == 0) {
 
 1414        $maxCountMergeCellsPerRecord = 1027;
 
 1429        foreach ($mergeCells as $mergeCell) {
 
 1435            [$first, $last] = $range[0];
 
 1439            $recordData .= pack(
'vvvv', $firstRow - 1, $lastRow - 1, $firstColumn - 1, $lastColumn - 1);
 
 1442            if ($j == $maxCountMergeCellsPerRecord || 
$i == $countMergeCells) {
 
 1443                $recordData = pack(
'v', $j) . $recordData;
 
 1444                $length = strlen($recordData);
 
 1445                $header = pack(
'vv', $record, $length);
 
 1446                $this->append(
$header . $recordData);
 
 1460        if (!$this->phpSheet->isTabColorSet()) {
 
 1471            $this->colors[$this->phpSheet->getTabColor()->getRGB()], 
 
 1475        $length = strlen($recordData);
 
 1478        $header = pack(
'vv', $record, $length);
 
 1479        $this->append(
$header . $recordData);
 
 1491        $options = (int) !$this->phpSheet->getProtection()->getObjects()
 
 1492            | (int) !$this->phpSheet->getProtection()->getScenarios() << 1
 
 1493            | (int) !$this->phpSheet->getProtection()->getFormatCells() << 2
 
 1494            | (int) !$this->phpSheet->getProtection()->getFormatColumns() << 3
 
 1495            | (int) !$this->phpSheet->getProtection()->getFormatRows() << 4
 
 1496            | (int) !$this->phpSheet->getProtection()->getInsertColumns() << 5
 
 1497            | (int) !$this->phpSheet->getProtection()->getInsertRows() << 6
 
 1498            | (int) !$this->phpSheet->getProtection()->getInsertHyperlinks() << 7
 
 1499            | (int) !$this->phpSheet->getProtection()->getDeleteColumns() << 8
 
 1500            | (int) !$this->phpSheet->getProtection()->getDeleteRows() << 9
 
 1501            | (int) !$this->phpSheet->getProtection()->getSelectLockedCells() << 10
 
 1502            | (int) !$this->phpSheet->getProtection()->getSort() << 11
 
 1503            | (int) !$this->phpSheet->getProtection()->getAutoFilter() << 12
 
 1504            | (int) !$this->phpSheet->getProtection()->getPivotTables() << 13
 
 1505            | (int) !$this->phpSheet->getProtection()->getSelectUnlockedCells() << 14;
 
 1520        $length = strlen($recordData);
 
 1521        $header = pack(
'vv', $record, $length);
 
 1523        $this->append(
$header . $recordData);
 
 1534        foreach ($this->phpSheet->getProtectedCells() as $range => 
$password) {
 
 1536            $cellRanges = explode(
' ', $range);
 
 1537            $cref = count($cellRanges);
 
 1553            foreach ($cellRanges as $cellRange) {
 
 1554                $recordData .= $this->writeBIFF8CellRangeAddressFixed($cellRange);
 
 1558            $recordData .= pack(
 
 1566            $length = strlen($recordData);
 
 1569            $header = pack(
'vv', $record, $length);
 
 1570            $this->append(
$header . $recordData);
 
 1582        if (!$this->phpSheet->getFreezePane()) {
 
 1593        $rwTop = $topRow - 1;
 
 1594        $colLeft = $leftMostColumn - 1;
 
 1602        if (
$x != 0 && 
$y != 0) {
 
 1605        if (
$x != 0 && 
$y == 0) {
 
 1608        if (
$x == 0 && 
$y != 0) {
 
 1611        if (
$x == 0 && 
$y == 0) {
 
 1615        $this->activePane = $pnnAct; 
 
 1617        $header = pack(
'vv', $record, $length);
 
 1618        $data = pack(
'vvvvv', 
$x, 
$y, $rwTop, $colLeft, $pnnAct);
 
 1630        $iPaperSize = $this->phpSheet->getPageSetup()->getPaperSize(); 
 
 1631        $iScale = $this->phpSheet->getPageSetup()->getScale() ?: 100; 
 
 1634        $iFitWidth = (int) $this->phpSheet->getPageSetup()->getFitToWidth(); 
 
 1635        $iFitHeight = (int) $this->phpSheet->getPageSetup()->getFitToHeight(); 
 
 1640        $numHdr = $this->phpSheet->getPageMargins()->getHeader(); 
 
 1642        $numFtr = $this->phpSheet->getPageMargins()->getFooter(); 
 
 1659        $grbit = $fLeftToRight;
 
 1660        $grbit |= $fLandscape << 1;
 
 1661        $grbit |= $fNoPls << 2;
 
 1662        $grbit |= $fNoColor << 3;
 
 1663        $grbit |= $fDraft << 4;
 
 1664        $grbit |= $fNotes << 5;
 
 1665        $grbit |= $fNoOrient << 6;
 
 1666        $grbit |= $fUsePage << 7;
 
 1668        $numHdr = pack(
'd', $numHdr);
 
 1669        $numFtr = pack(
'd', $numFtr);
 
 1670        if (self::getByteOrder()) { 
 
 1671            $numHdr = strrev($numHdr);
 
 1672            $numFtr = strrev($numFtr);
 
 1675        $header = pack(
'vv', $record, $length);
 
 1676        $data1 = pack(
'vvvvvvvv', $iPaperSize, $iScale, $iPageStart, $iFitWidth, $iFitHeight, $grbit, $iRes, $iVRes);
 
 1677        $data2 = $numHdr . $numFtr;
 
 1678        $data3 = pack(
'v', $iCopies);
 
 1679        $this->append(
$header . $data1 . $data2 . $data3);
 
 1699        $length = strlen($recordData);
 
 1701        $header = pack(
'vv', $record, $length);
 
 1703        $this->append(
$header . $recordData);
 
 1723        $length = strlen($recordData);
 
 1725        $header = pack(
'vv', $record, $length);
 
 1727        $this->append(
$header . $recordData);
 
 1738        $fHCenter = $this->phpSheet->getPageSetup()->getHorizontalCentered() ? 1 : 0; 
 
 1740        $header = pack(
'vv', $record, $length);
 
 1741        $data = pack(
'v', $fHCenter);
 
 1754        $fVCenter = $this->phpSheet->getPageSetup()->getVerticalCentered() ? 1 : 0; 
 
 1756        $header = pack(
'vv', $record, $length);
 
 1757        $data = pack(
'v', $fVCenter);
 
 1769        $margin = $this->phpSheet->getPageMargins()->getLeft(); 
 
 1771        $header = pack(
'vv', $record, $length);
 
 1772        $data = pack(
'd', $margin);
 
 1773        if (self::getByteOrder()) { 
 
 1788        $margin = $this->phpSheet->getPageMargins()->getRight(); 
 
 1790        $header = pack(
'vv', $record, $length);
 
 1791        $data = pack(
'd', $margin);
 
 1792        if (self::getByteOrder()) { 
 
 1807        $margin = $this->phpSheet->getPageMargins()->getTop(); 
 
 1809        $header = pack(
'vv', $record, $length);
 
 1810        $data = pack(
'd', $margin);
 
 1811        if (self::getByteOrder()) { 
 
 1826        $margin = $this->phpSheet->getPageMargins()->getBottom(); 
 
 1828        $header = pack(
'vv', $record, $length);
 
 1829        $data = pack(
'd', $margin);
 
 1830        if (self::getByteOrder()) { 
 
 1845        $fPrintRwCol = $this->printHeaders; 
 
 1847        $header = pack(
'vv', $record, $length);
 
 1848        $data = pack(
'v', $fPrintRwCol);
 
 1861        $fPrintGrid = $this->phpSheet->getPrintGridlines() ? 1 : 0; 
 
 1863        $header = pack(
'vv', $record, $length);
 
 1864        $data = pack(
'v', $fPrintGrid);
 
 1877        $fGridSet = !$this->phpSheet->getPrintGridlines(); 
 
 1879        $header = pack(
'vv', $record, $length);
 
 1880        $data = pack(
'v', $fGridSet);
 
 1893        $iNumFilters = 1 + $rangeBounds[1][0] - $rangeBounds[0][0];
 
 1895        $header = pack(
'vv', $record, $length);
 
 1896        $data = pack(
'v', $iNumFilters);
 
 1916        $maxRowOutlineLevel = 0;
 
 1917        foreach ($this->phpSheet->getRowDimensions() as $rowDimension) {
 
 1918            $maxRowOutlineLevel = max($maxRowOutlineLevel, $rowDimension->getOutlineLevel());
 
 1925        $colcount = count($this->columnInfo);
 
 1926        for (
$i = 0; 
$i < $colcount; ++
$i) {
 
 1927            $col_level = max($this->columnInfo[
$i][5], $col_level);
 
 1931        $col_level = max(0, min($col_level, 7));
 
 1934        if ($maxRowOutlineLevel) {
 
 1935            ++$maxRowOutlineLevel;
 
 1941        $header = pack(
'vv', $record, $length);
 
 1942        $data = pack(
'vvvv', $dxRwGut, $dxColGut, $maxRowOutlineLevel, $col_level);
 
 1962        if ($this->outlineStyle) {
 
 1965        if ($this->phpSheet->getShowSummaryBelow()) {
 
 1968        if ($this->phpSheet->getShowSummaryRight()) {
 
 1971        if ($this->phpSheet->getPageSetup()->getFitToPage()) {
 
 1974        if ($this->outlineOn) {
 
 1978        $header = pack(
'vv', $record, $length);
 
 1979        $data = pack(
'v', $grbit);
 
 1992        foreach ($this->phpSheet->getBreaks() as $cell => $breakType) {
 
 1997            switch ($breakType) {
 
 1998                case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_COLUMN:
 
 2003                case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_ROW:
 
 2005                    $hbreaks[] = $coordinates[1];
 
 2008                case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_NONE:
 
 2016        if (!empty($hbreaks)) {
 
 2018            sort($hbreaks, SORT_NUMERIC);
 
 2019            if ($hbreaks[0] == 0) { 
 
 2020                array_shift($hbreaks);
 
 2024            $cbrk = count($hbreaks); 
 
 2025            $length = 2 + 6 * $cbrk; 
 
 2027            $header = pack(
'vv', $record, $length);
 
 2028            $data = pack(
'v', $cbrk);
 
 2031            foreach ($hbreaks as $hbreak) {
 
 2032                $data .= pack(
'vvv', $hbreak, 0x0000, 0x00ff);
 
 2039        if (!empty($vbreaks)) {
 
 2042            $vbreaks = array_slice($vbreaks, 0, 1000);
 
 2045            sort($vbreaks, SORT_NUMERIC);
 
 2046            if ($vbreaks[0] == 0) { 
 
 2047                array_shift($vbreaks);
 
 2051            $cbrk = count($vbreaks); 
 
 2052            $length = 2 + 6 * $cbrk; 
 
 2054            $header = pack(
'vv', $record, $length);
 
 2055            $data = pack(
'v', $cbrk);
 
 2058            foreach ($vbreaks as $vbreak) {
 
 2059                $data .= pack(
'vvv', $vbreak, 0x0000, 0xffff);
 
 2072        if (!$this->phpSheet->getProtection()->getSheet()) {
 
 2081        $header = pack(
'vv', $record, $length);
 
 2082        $data = pack(
'v', $fLock);
 
 2093        if (!$this->phpSheet->getProtection()->getSheet()) {
 
 2098        if (!$this->phpSheet->getProtection()->getScenarios()) {
 
 2105        $header = pack(
'vv', $record, $length);
 
 2106        $data = pack(
'v', 1);
 
 2117        if (!$this->phpSheet->getProtection()->getSheet()) {
 
 2122        if (!$this->phpSheet->getProtection()->getObjects()) {
 
 2129        $header = pack(
'vv', $record, $length);
 
 2130        $data = pack(
'v', 1);
 
 2141        if (!$this->phpSheet->getProtection()->getSheet() || !$this->phpSheet->getProtection()->getPassword()) {
 
 2148        $wPassword = hexdec($this->phpSheet->getProtection()->getPassword()); 
 
 2150        $header = pack(
'vv', $record, $length);
 
 2151        $data = pack(
'v', $wPassword);
 
 2169        $bitmap_array = (is_resource($bitmap) || $bitmap instanceof GdImage
 
 2170            ? $this->processBitmapGd($bitmap)
 
 2171            : $this->processBitmap($bitmap));
 
 2172        [$width, $height, 
$size, 
$data] = $bitmap_array;
 
 2176        $height *= $scale_y;
 
 2179        $this->positionImage($col, 
$row, 
$x, 
$y, $width, $height);
 
 2183        $length = 8 + 
$size;
 
 2188        $header = pack(
'vvvvV', $record, $length, $cf, 
$env, $lcb);
 
 2242    public function positionImage($col_start, $row_start, $x1, $y1, $width, $height): void
 
 2245        $col_end = $col_start; 
 
 2246        $row_end = $row_start; 
 
 2252        if ($y1 >= Xls::sizeRow($this->phpSheet, $row_start + 1)) {
 
 2256        $width = $width + $x1 - 1;
 
 2257        $height = $height + $y1 - 1;
 
 2266        while ($height >= Xls::sizeRow($this->phpSheet, $row_end + 1)) {
 
 2267            $height -= Xls::sizeRow($this->phpSheet, $row_end + 1);
 
 2280        if (Xls::sizeRow($this->phpSheet, $row_start + 1) == 0) {
 
 2283        if (Xls::sizeRow($this->phpSheet, $row_end + 1) == 0) {
 
 2289        $y1 = $y1 / Xls::sizeRow($this->phpSheet, $row_start + 1) * 256;
 
 2291        $y2 = $height / Xls::sizeRow($this->phpSheet, $row_end + 1) * 256; 
 
 2293        $this->writeObjPicture($col_start, $x1, $row_start, $y1, $col_end, $x2, $row_end, $y2);
 
 2320        $Reserved1 = 0x0000; 
 
 2321        $Reserved2 = 0x0000; 
 
 2333        $Reserved3 = 0x0000; 
 
 2334        $cbPictFmla = 0x0000; 
 
 2335        $Reserved4 = 0x0000; 
 
 2337        $Reserved5 = 0x0000; 
 
 2339        $header = pack(
'vv', $record, $length);
 
 2340        $data = pack(
'V', $cObj);
 
 2341        $data .= pack(
'v', $OT);
 
 2343        $data .= pack(
'v', $grbit);
 
 2344        $data .= pack(
'v', $colL);
 
 2345        $data .= pack(
'v', $dxL);
 
 2346        $data .= pack(
'v', $rwT);
 
 2347        $data .= pack(
'v', $dyT);
 
 2348        $data .= pack(
'v', $colR);
 
 2349        $data .= pack(
'v', $dxR);
 
 2350        $data .= pack(
'v', $rwB);
 
 2351        $data .= pack(
'v', $dyB);
 
 2352        $data .= pack(
'v', $cbMacro);
 
 2353        $data .= pack(
'V', $Reserved1);
 
 2354        $data .= pack(
'v', $Reserved2);
 
 2355        $data .= pack(
'C', $icvBack);
 
 2356        $data .= pack(
'C', $icvFore);
 
 2357        $data .= pack(
'C', $fls);
 
 2358        $data .= pack(
'C', $fAuto);
 
 2359        $data .= pack(
'C', $icv);
 
 2360        $data .= pack(
'C', $lns);
 
 2361        $data .= pack(
'C', $lnw);
 
 2362        $data .= pack(
'C', $fAutoB);
 
 2363        $data .= pack(
'v', $frs);
 
 2364        $data .= pack(
'V', $cf);
 
 2365        $data .= pack(
'v', $Reserved3);
 
 2366        $data .= pack(
'v', $cbPictFmla);
 
 2367        $data .= pack(
'v', $Reserved4);
 
 2368        $data .= pack(
'v', $grbit2);
 
 2369        $data .= pack(
'V', $Reserved5);
 
 2383        $width = imagesx($image);
 
 2384        $height = imagesy($image);
 
 2386        $data = pack(
'Vvvvv', 0x000c, $width, $height, 0x01, 0x18);
 
 2387        for ($j = $height; --$j;) {
 
 2388            for (
$i = 0; 
$i < $width; ++
$i) {
 
 2389                $color = imagecolorsforindex($image, imagecolorat($image, 
$i, $j));
 
 2390                foreach ([
'red', 
'green', 
'blue'] as 
$key) {
 
 2391                    $color[
$key] = $color[
$key] + round((255 - $color[
$key]) * $color[
'alpha'] / 127);
 
 2393                $data .= chr($color[
'blue']) . chr($color[
'green']) . chr($color[
'red']);
 
 2395            if (3 * $width % 4) {
 
 2396                $data .= str_repeat(
"\x00", 4 - 3 * $width % 4);
 
 2400        return [$width, $height, strlen(
$data), 
$data];
 
 2415        $bmp_fd = @fopen($bitmap, 
'rb');
 
 2417            throw new WriterException(
"Couldn't import $bitmap");
 
 2421        $data = fread($bmp_fd, filesize($bitmap));
 
 2424        if (strlen(
$data) <= 0x36) {
 
 2425            throw new WriterException(
"$bitmap doesn't contain enough data.\n");
 
 2429        $identity = unpack(
'A2ident', 
$data);
 
 2430        if ($identity[
'ident'] != 
'BM') {
 
 2431            throw new WriterException(
"$bitmap doesn't appear to be a valid bitmap image.\n");
 
 2440        $size_array = unpack(
'Vsa', substr(
$data, 0, 4));
 
 2441        $size = $size_array[
'sa'];
 
 2450        $width_and_height = unpack(
'V2', substr(
$data, 0, 8));
 
 2451        $width = $width_and_height[1];
 
 2452        $height = $width_and_height[2];
 
 2454        if ($width > 0xFFFF) {
 
 2455            throw new WriterException(
"$bitmap: largest image width supported is 65k.\n");
 
 2457        if ($height > 0xFFFF) {
 
 2458            throw new WriterException(
"$bitmap: largest image height supported is 65k.\n");
 
 2462        $planes_and_bitcount = unpack(
'v2', substr(
$data, 0, 4));
 
 2464        if ($planes_and_bitcount[2] != 24) { 
 
 2465            throw new WriterException(
"$bitmap isn't a 24bit true color bitmap.\n");
 
 2467        if ($planes_and_bitcount[1] != 1) {
 
 2468            throw new WriterException(
"$bitmap: only 1 plane supported in bitmap image.\n");
 
 2472        $compression = unpack(
'Vcomp', substr(
$data, 0, 4));
 
 2475        if ($compression[
'comp'] != 0) {
 
 2476            throw new WriterException(
"$bitmap: compression not supported in bitmap image.\n");
 
 2483        $header = pack(
'Vvvvv', 0x000c, $width, $height, 0x01, 0x18);
 
 2496        if ($this->phpSheet->getSheetView()->getZoomScale() == 100) {
 
 2503        $header = pack(
'vv', $record, $length);
 
 2504        $data = pack(
'vv', $this->phpSheet->getSheetView()->getZoomScale(), 100);
 
 2515        return $this->escher;
 
 2525        $this->escher = $pValue;
 
 2534        if (isset($this->escher)) {
 
 2535            $writer = 
new Escher($this->escher);
 
 2536            $data = $writer->close();
 
 2537            $spOffsets = $writer->getSpOffsets();
 
 2538            $spTypes = $writer->getSpTypes();
 
 2543            $nm = count($spOffsets) - 1; 
 
 2544            for (
$i = 1; 
$i <= $nm; ++
$i) {
 
 2549                $dataChunk = substr(
$data, $spOffsets[
$i - 1], $spOffsets[
$i] - $spOffsets[
$i - 1]);
 
 2551                $length = strlen($dataChunk);
 
 2552                $header = pack(
'vv', $record, $length);
 
 2554                $this->append(
$header . $dataChunk);
 
 2561                if ($spTypes[
$i] == 0x00C9) {
 
 2577                    $objData .= pack(
'vv', 0x00C, 0x0014);
 
 2578                    $objData .= pack(
'H*', 
'0000000000000000640001000A00000010000100');
 
 2580                    $objData .= pack(
'vv', 0x0013, 0x1FEE);
 
 2581                    $objData .= pack(
'H*', 
'00000000010001030000020008005700');
 
 2606                $length = strlen($objData);
 
 2607                $header = pack(
'vv', $record, $length);
 
 2608                $this->append(
$header . $objData);
 
 2619        $dataValidationCollection = $this->phpSheet->getDataValidationCollection();
 
 2622        if (!empty($dataValidationCollection)) {
 
 2628            $horPos = 0x00000000; 
 
 2629            $verPos = 0x00000000; 
 
 2630            $objId = 0xFFFFFFFF; 
 
 2632            $header = pack(
'vv', $record, $length);
 
 2633            $data = pack(
'vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection));
 
 2639            foreach ($dataValidationCollection as $cellCoordinate => $dataValidation) {
 
 2654                if (
$type == 0x03 && preg_match(
'/^\".*\"$/', $dataValidation->getFormula1())) {
 
 2659                $options |= $dataValidation->getAllowBlank() << 8;
 
 2662                $options |= (!$dataValidation->getShowDropDown()) << 9;
 
 2665                $options |= $dataValidation->getShowInputMessage() << 18;
 
 2668                $options |= $dataValidation->getShowErrorMessage() << 19;
 
 2678                $promptTitle = $dataValidation->getPromptTitle() !== 
'' ?
 
 2679                    $dataValidation->getPromptTitle() : chr(0);
 
 2683                $errorTitle = $dataValidation->getErrorTitle() !== 
'' ?
 
 2684                    $dataValidation->getErrorTitle() : chr(0);
 
 2688                $prompt = $dataValidation->getPrompt() !== 
'' ?
 
 2689                    $dataValidation->getPrompt() : chr(0);
 
 2693                $error = $dataValidation->getError() !== 
'' ?
 
 2694                    $dataValidation->getError() : chr(0);
 
 2699                    $formula1 = $dataValidation->getFormula1();
 
 2700                    if (
$type == 0x03) { 
 
 2701                        $formula1 = str_replace(
',', chr(0), $formula1);
 
 2703                    $this->parser->parse($formula1);
 
 2704                    $formula1 = $this->parser->toReversePolish();
 
 2705                    $sz1 = strlen($formula1);
 
 2706                } 
catch (PhpSpreadsheetException $e) {
 
 2710                $data .= pack(
'vv', $sz1, 0x0000);
 
 2715                    $formula2 = $dataValidation->getFormula2();
 
 2716                    if ($formula2 === 
'') {
 
 2717                        throw new WriterException(
'No formula2');
 
 2719                    $this->parser->parse($formula2);
 
 2720                    $formula2 = $this->parser->toReversePolish();
 
 2721                    $sz2 = strlen($formula2);
 
 2722                } 
catch (PhpSpreadsheetException $e) {
 
 2726                $data .= pack(
'vv', $sz2, 0x0000);
 
 2730                $data .= pack(
'v', 0x0001);
 
 2731                $data .= $this->writeBIFF8CellRangeAddressFixed($cellCoordinate);
 
 2733                $length = strlen(
$data);
 
 2734                $header = pack(
'vv', $record, $length);
 
 2751        $reserved = 0x0000000000000000; 
 
 2752        $wScalvePLV = $this->phpSheet->getSheetView()->getZoomScale(); 
 
 2756            $fPageLayoutView = 1;
 
 2758            $fPageLayoutView = 0;
 
 2761        $fWhitespaceHidden = 0;
 
 2763        $grbit = $fPageLayoutView; 
 
 2764        $grbit |= $fRulerVisible << 1;
 
 2765        $grbit |= $fWhitespaceHidden << 3;
 
 2767        $header = pack(
'vv', $record, $length);
 
 2768        $data = pack(
'vvVVvv', $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit);
 
 2779        $operatorType = 
null;   
 
 2783            $operatorType = 0x00;
 
 2789                    $operatorType = 0x00;
 
 2793                    $operatorType = 0x03;
 
 2797                    $operatorType = 0x05;
 
 2801                    $operatorType = 0x07;
 
 2805                    $operatorType = 0x06;
 
 2809                    $operatorType = 0x08;
 
 2813                    $operatorType = 0x04;
 
 2817                    $operatorType = 0x01;
 
 2827        $numConditions = count($arrConditions);
 
 2828        if ($numConditions == 1) {
 
 2829            $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000);
 
 2831            $operand1 = pack(
'Cv', 0x1E, $arrConditions[0]);
 
 2834            $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000);
 
 2835            $szValue2 = ($arrConditions[1] <= 65535 ? 3 : 0x0000);
 
 2836            $operand1 = pack(
'Cv', 0x1E, $arrConditions[0]);
 
 2837            $operand2 = pack(
'Cv', 0x1E, $arrConditions[1]);
 
 2847        $bAlignHz = ($conditional->
getStyle()->getAlignment()->getHorizontal() === 
null ? 1 : 0);
 
 2848        $bAlignVt = ($conditional->
getStyle()->getAlignment()->getVertical() === 
null ? 1 : 0);
 
 2849        $bAlignWrapTx = ($conditional->
getStyle()->getAlignment()->getWrapText() === 
false ? 1 : 0);
 
 2850        $bTxRotation = ($conditional->
getStyle()->getAlignment()->getTextRotation() === 
null ? 1 : 0);
 
 2851        $bIndent = ($conditional->
getStyle()->getAlignment()->getIndent() === 0 ? 1 : 0);
 
 2852        $bShrinkToFit = ($conditional->
getStyle()->getAlignment()->getShrinkToFit() === 
false ? 1 : 0);
 
 2853        if ($bAlignHz == 0 || $bAlignVt == 0 || $bAlignWrapTx == 0 || $bTxRotation == 0 || $bIndent == 0 || $bShrinkToFit == 0) {
 
 2859        $bProtLocked = ($conditional->
getStyle()->getProtection()->getLocked() == 
null ? 1 : 0);
 
 2860        $bProtHidden = ($conditional->
getStyle()->getProtection()->getHidden() == 
null ? 1 : 0);
 
 2861        if ($bProtLocked == 0 || $bProtHidden == 0) {
 
 2875        if ($bBorderLeft == 0 || $bBorderRight == 0 || $bBorderTop == 0 || $bBorderBottom == 0) {
 
 2881        $bFillStyle = ($conditional->
getStyle()->getFill()->getFillType() === 
null ? 0 : 1);
 
 2882        $bFillColor = ($conditional->
getStyle()->getFill()->getStartColor()->getARGB() == 
null ? 0 : 1);
 
 2883        $bFillColorBg = ($conditional->
getStyle()->getFill()->getEndColor()->getARGB() == 
null ? 0 : 1);
 
 2884        if ($bFillStyle == 0 || $bFillColor == 0 || $bFillColorBg == 0) {
 
 2891            $conditional->
getStyle()->getFont()->getName() !== 
null 
 2892            || $conditional->
getStyle()->getFont()->getSize() !== 
null 
 2893            || $conditional->
getStyle()->getFont()->getBold() !== 
null 
 2894            || $conditional->
getStyle()->getFont()->getItalic() !== 
null 
 2895            || $conditional->
getStyle()->getFont()->getSuperscript() !== 
null 
 2896            || $conditional->
getStyle()->getFont()->getSubscript() !== 
null 
 2897            || $conditional->
getStyle()->getFont()->getUnderline() !== 
null 
 2898            || $conditional->
getStyle()->getFont()->getStrikethrough() !== 
null 
 2899            || $conditional->
getStyle()->getFont()->getColor()->getARGB() != null
 
 2907        $flags |= (1 == $bAlignHz ? 0x00000001 : 0);
 
 2908        $flags |= (1 == $bAlignVt ? 0x00000002 : 0);
 
 2909        $flags |= (1 == $bAlignWrapTx ? 0x00000004 : 0);
 
 2910        $flags |= (1 == $bTxRotation ? 0x00000008 : 0);
 
 2912        $flags |= (1 == 1 ? 0x00000010 : 0);
 
 2913        $flags |= (1 == $bIndent ? 0x00000020 : 0);
 
 2914        $flags |= (1 == $bShrinkToFit ? 0x00000040 : 0);
 
 2916        $flags |= (1 == 1 ? 0x00000080 : 0);
 
 2918        $flags |= (1 == $bProtLocked ? 0x00000100 : 0);
 
 2919        $flags |= (1 == $bProtHidden ? 0x00000200 : 0);
 
 2921        $flags |= (1 == $bBorderLeft ? 0x00000400 : 0);
 
 2922        $flags |= (1 == $bBorderRight ? 0x00000800 : 0);
 
 2923        $flags |= (1 == $bBorderTop ? 0x00001000 : 0);
 
 2924        $flags |= (1 == $bBorderBottom ? 0x00002000 : 0);
 
 2925        $flags |= (1 == 1 ? 0x00004000 : 0); 
 
 2926        $flags |= (1 == 1 ? 0x00008000 : 0); 
 
 2928        $flags |= (1 == $bFillStyle ? 0x00010000 : 0);
 
 2929        $flags |= (1 == $bFillColor ? 0x00020000 : 0);
 
 2930        $flags |= (1 == $bFillColorBg ? 0x00040000 : 0);
 
 2931        $flags |= (1 == 1 ? 0x00380000 : 0);
 
 2933        $flags |= (1 == $bFormatFont ? 0x04000000 : 0);
 
 2935        $flags |= (1 == $bFormatAlign ? 0x08000000 : 0);
 
 2937        $flags |= (1 == $bFormatBorder ? 0x10000000 : 0);
 
 2939        $flags |= (1 == $bFormatFill ? 0x20000000 : 0);
 
 2941        $flags |= (1 == $bFormatProt ? 0x40000000 : 0);
 
 2943        $flags |= (1 == 0 ? 0x80000000 : 0);
 
 2945        $dataBlockFont = 
null;
 
 2946        $dataBlockAlign = 
null;
 
 2947        $dataBlockBorder = 
null;
 
 2948        $dataBlockFill = 
null;
 
 2951        if ($bFormatFont == 1) {
 
 2953            if ($conditional->
getStyle()->getFont()->getName() === 
null) {
 
 2954                $dataBlockFont = pack(
'VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000);
 
 2955                $dataBlockFont .= pack(
'VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000);
 
 2960            if ($conditional->
getStyle()->getFont()->getSize() === 
null) {
 
 2961                $dataBlockFont .= pack(
'V', 20 * 11);
 
 2963                $dataBlockFont .= pack(
'V', 20 * $conditional->
getStyle()->getFont()->getSize());
 
 2966            $dataBlockFont .= pack(
'V', 0);
 
 2968            if ($conditional->
getStyle()->getFont()->getBold() === 
true) {
 
 2969                $dataBlockFont .= pack(
'v', 0x02BC);
 
 2971                $dataBlockFont .= pack(
'v', 0x0190);
 
 2974            if ($conditional->
getStyle()->getFont()->getSubscript() === 
true) {
 
 2975                $dataBlockFont .= pack(
'v', 0x02);
 
 2976                $fontEscapement = 0;
 
 2977            } elseif ($conditional->
getStyle()->getFont()->getSuperscript() === 
true) {
 
 2978                $dataBlockFont .= pack(
'v', 0x01);
 
 2979                $fontEscapement = 0;
 
 2981                $dataBlockFont .= pack(
'v', 0x00);
 
 2982                $fontEscapement = 1;
 
 2985            switch ($conditional->
getStyle()->getFont()->getUnderline()) {
 
 2986                case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE:
 
 2987                    $dataBlockFont .= pack(
'C', 0x00);
 
 2991                case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE:
 
 2992                    $dataBlockFont .= pack(
'C', 0x02);
 
 2996                case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLEACCOUNTING:
 
 2997                    $dataBlockFont .= pack(
'C', 0x22);
 
 3001                case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE:
 
 3002                    $dataBlockFont .= pack(
'C', 0x01);
 
 3006                case \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING:
 
 3007                    $dataBlockFont .= pack(
'C', 0x21);
 
 3012                    $dataBlockFont .= pack(
'C', 0x00);
 
 3018            $dataBlockFont .= pack(
'vC', 0x0000, 0x00);
 
 3022            $dataBlockFont .= pack(
'V', $colorIdx);
 
 3024            $dataBlockFont .= pack(
'V', 0x00000000);
 
 3027            $optionsFlagsBold = ($conditional->
getStyle()->getFont()->getBold() === 
null ? 1 : 0);
 
 3028            $optionsFlags |= (1 == $optionsFlagsBold ? 0x00000002 : 0);
 
 3029            $optionsFlags |= (1 == 1 ? 0x00000008 : 0);
 
 3030            $optionsFlags |= (1 == 1 ? 0x00000010 : 0);
 
 3031            $optionsFlags |= (1 == 0 ? 0x00000020 : 0);
 
 3032            $optionsFlags |= (1 == 1 ? 0x00000080 : 0);
 
 3033            $dataBlockFont .= pack(
'V', $optionsFlags);
 
 3035            $dataBlockFont .= pack(
'V', $fontEscapement);
 
 3037            $dataBlockFont .= pack(
'V', $fontUnderline);
 
 3039            $dataBlockFont .= pack(
'V', 0x00000000);
 
 3041            $dataBlockFont .= pack(
'V', 0x00000000);
 
 3043            $dataBlockFont .= pack(
'VV', 0x00000000, 0x00000000);
 
 3045            $dataBlockFont .= pack(
'v', 0x0001);
 
 3047        if ($bFormatAlign === 1) {
 
 3052            $blockAlign |= 0 << 7;
 
 3055            $blockRotation = $conditional->
getStyle()->getAlignment()->getTextRotation();
 
 3058            $blockIndent = $conditional->
getStyle()->getAlignment()->getIndent();
 
 3059            if ($conditional->
getStyle()->getAlignment()->getShrinkToFit() === 
true) {
 
 3060                $blockIndent |= 1 << 4;
 
 3062                $blockIndent |= 0 << 4;
 
 3064            $blockIndent |= 0 << 6;
 
 3067            $blockIndentRelative = 255;
 
 3069            $dataBlockAlign = pack(
'CCvvv', $blockAlign, $blockRotation, $blockIndent, $blockIndentRelative, 0x0000);
 
 3071        if ($bFormatBorder === 1) {
 
 3086            $dataBlockBorder = pack(
'vv', $blockLineStyle, $blockColor);
 
 3088        if ($bFormatFill === 1) {
 
 3096            $dataBlockFill = pack(
'v', $blockFillPatternStyle);
 
 3097            $dataBlockFill .= pack(
'v', $colorIdxFg | ($colorIdxBg << 7));
 
 3100        $data = pack(
'CCvvVv', 
$type, $operatorType, $szValue1, $szValue2, $flags, 0x0000);
 
 3101        if ($bFormatFont === 1) { 
 
 3102            $data .= $dataBlockFont;
 
 3104        if ($bFormatAlign === 1) {
 
 3105            $data .= $dataBlockAlign;
 
 3107        if ($bFormatBorder === 1) {
 
 3108            $data .= $dataBlockBorder;
 
 3110        if ($bFormatFill === 1) { 
 
 3111            $data .= $dataBlockFill;
 
 3113        if ($bFormatProt == 1) {
 
 3114            $data .= $this->getDataBlockProtection($conditional);
 
 3116        if ($operand1 !== 
null) {
 
 3119        if ($operand2 !== 
null) {
 
 3134        $numColumnMin = 
null;
 
 3135        $numColumnMax = 
null;
 
 3138        $arrConditional = [];
 
 3139        foreach ($this->phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) {
 
 3140            foreach ($conditionalStyles as $conditional) {
 
 3145                    if (!in_array($conditional->getHashCode(), $arrConditional)) {
 
 3146                        $arrConditional[] = $conditional->getHashCode();
 
 3150                    if ($numColumnMin === 
null || ($numColumnMin > $rangeCoordinates[0][0])) {
 
 3151                        $numColumnMin = $rangeCoordinates[0][0];
 
 3153                    if ($numColumnMax === 
null || ($numColumnMax < $rangeCoordinates[1][0])) {
 
 3154                        $numColumnMax = $rangeCoordinates[1][0];
 
 3156                    if ($numRowMin === 
null || ($numRowMin > $rangeCoordinates[0][1])) {
 
 3157                        $numRowMin = (int) $rangeCoordinates[0][1];
 
 3159                    if ($numRowMax === 
null || ($numRowMax < $rangeCoordinates[1][1])) {
 
 3160                        $numRowMax = (int) $rangeCoordinates[1][1];
 
 3166        $cellRange = pack(
'vvvv', $numRowMin - 1, $numRowMax - 1, $numColumnMin - 1, $numColumnMax - 1);
 
 3168        $header = pack(
'vv', $record, $length);
 
 3169        $data = pack(
'vv', count($arrConditional), $needRedraw);
 
 3170        $data .= $cellRange;
 
 3171        $data .= pack(
'v', 0x0001);
 
 3172        $data .= $cellRange;
 
 3178        $dataBlockProtection = 0;
 
 3180            $dataBlockProtection = 1;
 
 3183            $dataBlockProtection = 1 << 1;
 
 3186        return $dataBlockProtection;
 
An exception for terminatinating execution or to throw for unit testing.
Helper class to manipulate cell coordinates.
static coordinateFromString($pCoordinateString)
Coordinate from string.
static indexesFromString(string $coordinates)
Get indexes from a string coordinates.
static columnIndexFromString($pString)
Column index from string.
static stringFromColumnIndex($columnIndex)
String from column index.
static splitRange($pRange)
Split range into coordinate strings.
static rangeBoundaries($pRange)
Calculate range boundaries.
static getErrorCodes()
Get list of error codes.
static getDefaultColumnWidthByFont(\PhpOffice\PhpSpreadsheet\Style\Font $font, $pPixels=false)
Get the effective column width for columns without a column dimension or column with width -1 For exa...
static countCharacters($value, $enc='UTF-8')
Get character count.
static UTF8toBIFF8UnicodeShort($value, $arrcRuns=[])
Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) Writes the string using ...
static UTF8toBIFF8UnicodeLong($value)
Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) Writes the string using...
static convertEncoding($value, $to, $from)
Convert string from one encoding to another.
getOperatorType()
Get Operator type.
const CONDITION_EXPRESSION
const OPERATOR_LESSTHANOREQUAL
getConditionType()
Get Condition type.
const OPERATOR_GREATERTHAN
const OPERATOR_GREATERTHANOREQUAL
getConditions()
Get Conditions.
const PROTECTION_PROTECTED
Paper size taken from Office Open XML Part 4 - Markup Language Reference, page 1988:.
const ORIENTATION_LANDSCAPE
const PAGEORDER_DOWN_THEN_OVER
const SHEETVIEW_PAGE_BREAK_PREVIEW
const SHEETVIEW_PAGE_LAYOUT
storeBof($type)
Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file.
append($data)
General storage function.
storeEof()
Writes Excel EOF record to indicate the end of a BIFF stream.
static operator(DataValidation $dataValidation)
static type(DataValidation $dataValidation)
static errorStyle(DataValidation $dataValidation)
static error(string $errorCode)
static vertical(Alignment $alignment)
static wrap(Alignment $alignment)
static horizontal(Alignment $alignment)
static style(Border $border)
static lookup(Color $color, int $defaultIndex=0x00)
writeHcenter()
Store the horizontal centering HCENTER BIFF record.
writeRow($row, $height, $xfIndex, $hidden=false, $level=0)
This method is used to set the height and format for a row.
writeGuts()
Write the GUTS BIFF record.
writePassword()
Write the worksheet PASSWORD record.
writeNumber($row, $col, $num, $xfIndex)
Write a double to the specified row and column (zero indexed).
writeSheetProtection()
Write SHEETPROTECTION.
writeProtect()
Set the Biff PROTECT record to indicate that the worksheet is protected.
writeUrlWeb($row1, $col1, $row2, $col2, $url)
Used to write http, ftp and mailto hyperlinks.
printRowColHeaders($print=1)
Set the option to print the row and column headers on the printed page.
writeMarginRight()
Store the RIGHTMARGIN BIFF record.
insertBitmap($row, $col, $bitmap, $x=0, $y=0, $scale_x=1, $scale_y=1)
Insert a 24bit bitmap image in a worksheet.
getEscher()
Get Escher object.
writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB)
Store the OBJ record that precedes an IMDATA record.
writeGridset()
Write the GRIDSET BIFF record.
writePrintGridlines()
Write the PRINTGRIDLINES BIFF record.
writeSelection()
Write BIFF record SELECTION.
writeObjectProtect()
Write OBJECTPROTECT.
writeString($row, $col, $str, $xfIndex)
Write a LABELSST record or a LABEL record.
writeCFHeader()
Write CFHeader record.
writeHeader()
Store the header caption BIFF record.
writeLabelSst($row, $col, $str, $xfIndex)
Write a string to the specified row and column (zero indexed).
writeRangeProtection()
Write BIFF record RANGEPROTECTION.
writeDefaultRowHeight()
Write BIFF record DEFAULTROWHEIGHT.
positionImage($col_start, $row_start, $x1, $y1, $width, $height)
Calculate the vertices that define the position of the image as required by the OBJ record.
writeSetup()
Store the page setup SETUP BIFF record.
writeCFRule(Conditional $conditional)
Write CFRule Record.
writeDataValidity()
Store the DATAVALIDATIONS and DATAVALIDATION records.
writeFooter()
Store the footer caption BIFF record.
getDataBlockProtection(Conditional $conditional)
writeAutoFilterInfo()
Write the AUTOFILTERINFO BIFF record.
writeScenProtect()
Write SCENPROTECT.
writePanes()
Writes the Excel BIFF PANE record.
writeDimensions()
Writes Excel DIMENSIONS to define the area in which there is data.
writeFormula($row, $col, $formula, $xfIndex, $calculatedValue)
Write a formula to the specified row and column (zero indexed).
const WRITE_FORMULA_ERRORS
writeBIFF8CellRangeAddressFixed($range)
Write a cell range address in BIFF8 always fixed range See section 2.5.14 in OpenOffice....
setOutline($visible=true, $symbols_below=true, $symbols_right=true, $auto_style=false)
This method sets the properties for outlining and grouping.
writeSheetLayout()
Write SHEETLAYOUT record.
const WRITE_FORMULA_EXCEPTION
if(preg_match('/^ $link_type[A-Z]:/', $url))
writeMsoDrawing()
Write MSODRAWING record.
processBitmapGd($image)
Convert a GD-image into the internal format.
writeZoom()
Store the window zoom factor.
writeUrlRange($row1, $col1, $row2, $col2, $url)
This is the more general form of writeUrl().
processBitmap($bitmap)
Convert a 24 bit bitmap into the modified internal format used by Windows.
writeUrl($row, $col, $url)
Write a hyperlink.
writeUrlInternal($row1, $col1, $row2, $col2, $url)
Used to write internal reference hyperlinks such as "Sheet1!A1".
writeUrlExternal($row1, $col1, $row2, $col2, $url)
Write links to external directory names such as 'c:\foo.xls', c:\foo.xls::Sheet1!A1',...
writePrintHeaders()
Write the PRINTHEADERS BIFF record.
writeWindow2()
Write BIFF record Window2.
writeColinfo($col_array)
Write BIFF record COLINFO to define column widths.
writeDefcol()
Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
getData()
Retrieves data from memory in one chunk, or from disk sized chunks.
writeRichTextString($row, $col, $str, $xfIndex, $arrcRun)
Write a LABELSST record or a LABEL record.
writeMarginLeft()
Store the LEFTMARGIN BIFF record.
writeBlank($row, $col, $xfIndex)
Write a blank cell to the specified row and column (zero indexed).
writeBreaks()
Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records.
writeBoolErr($row, $col, $value, $isError, $xfIndex)
Write a boolean or an error type to the specified row and column (zero indexed).
__construct(&$str_total, &$str_unique, &$str_table, &$colors, Parser $parser, $preCalculateFormulas, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet)
Constructor.
writeStringRecord($stringValue)
Write a STRING record.
writeMarginBottom()
Store the BOTTOMMARGIN BIFF record.
setEscher(?\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue=null)
Set Escher object.
writeVcenter()
Store the vertical centering VCENTER BIFF record.
writePageLayoutView()
Write PLV Record.
writeMergedCells()
Store the MERGEDCELLS records for all ranges of merged cells.
writeWsbool()
Write the WSBOOL BIFF record, mainly for fit-to-page.
const WRITE_FORMULA_RANGE
const WRITE_FORMULA_NORMAL
writeMarginTop()
Store the TOPMARGIN BIFF record.
if(!array_key_exists('StateId', $_REQUEST)) $id