214 public function __construct(&$str_total, &$str_unique, &$str_table, &$colors,
215 $parser, $preCalculateFormulas, $phpSheet)
218 parent::__construct();
224 $this->_preCalculateFormulas = $preCalculateFormulas;
225 $this->_str_total = &$str_total;
226 $this->_str_unique = &$str_unique;
227 $this->_str_table = &$str_table;
228 $this->_colors = &$colors;
231 $this->_phpSheet = $phpSheet;
235 $this->_xls_strmax = 255;
236 $this->_colinfo =
array();
237 $this->_selection =
array(0,0,0,0);
238 $this->_active_pane = 3;
240 $this->_print_headers = 0;
242 $this->_outline_style = 0;
243 $this->_outline_below = 1;
244 $this->_outline_right = 1;
245 $this->_outline_on = 1;
247 $this->_fntHashIndex =
array();
253 $maxR = $this->_phpSheet->getHighestRow();
254 $maxC = $this->_phpSheet->getHighestColumn();
258 $this->_lastRowIndex = ($maxR > 65535) ? 65535 : $maxR ;
264 if ($this->_lastColumnIndex > 255) $this->_lastColumnIndex = 255;
266 $this->_countCellStyleXfs = count($phpSheet->getParent()->getCellStyleXfCollection());
280 $num_sheets =
$_phpSheet->getParent()->getSheetCount();
298 if (($defaultWidth =
$_phpSheet->getDefaultColumnDimension()->getWidth()) < 0) {
302 $columnDimensions =
$_phpSheet->getColumnDimensions();
303 $maxCol = $this->_lastColumnIndex -1;
304 for ($i = 0; $i <= $maxCol; ++$i) {
309 $width = $defaultWidth;
312 if (isset($columnDimensions[$columnLetter])) {
313 $columnDimension = $columnDimensions[$columnLetter];
314 if ($columnDimension->getWidth() >= 0) {
315 $width = $columnDimension->getWidth();
317 $hidden = $columnDimension->getVisible() ? 0 : 1;
318 $level = $columnDimension->getOutlineLevel();
319 $xfIndex = $columnDimension->getXfIndex() + 15;
329 $this->_colinfo[] =
array($i, $i, $width, $xfIndex, $hidden, $level);
387 if (!empty($this->_colinfo)) {
388 $colcount = count($this->_colinfo);
389 for ($i = 0; $i < $colcount; ++$i) {
393 $autoFilterRange =
$_phpSheet->getAutoFilter()->getRange();
394 if (!empty($autoFilterRange)) {
403 foreach (
$_phpSheet->getRowDimensions() as $rowDimension) {
404 $xfIndex = $rowDimension->getXfIndex() + 15;
405 $this->
_writeRow( $rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), $xfIndex, ($rowDimension->getVisible() ?
'0' :
'1'), $rowDimension->getOutlineLevel() );
409 foreach (
$_phpSheet->getCellCollection() as $cellID) {
411 $row = $cell->getRow() - 1;
421 $xfIndex = $cell->getXfIndex() + 15;
423 $cVal = $cell->getValue();
429 $elements = $cVal->getRichTextElements();
430 foreach ($elements as $element) {
433 $str_fontidx = $this->_fntHashIndex[$element->getFont()->getHashCode()];
438 $arrcRun[] =
array(
'strlen' => $str_pos,
'fontidx' => $str_fontidx);
444 switch ($cell->getDatatype()) {
447 if ($cVal ===
'' || $cVal === null) {
459 $calculatedValue = $this->_preCalculateFormulas ?
460 $cell->getCalculatedValue() : null;
498 foreach (
$_phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
501 $url = $hyperlink->getUrl();
503 if ( strpos(
$url,
'sheet://') !==
false ) {
505 $url = str_replace(
'sheet://',
'internal:',
$url);
507 }
else if ( preg_match(
'/^(http:|https:|ftp:|mailto:)/',
$url) ) {
526 $arrConditionalStyles =
$_phpSheet->getConditionalStylesCollection();
527 if(!empty($arrConditionalStyles)){
528 $arrConditional =
array();
537 if(!in_array($conditional->getHashCode(), $arrConditional)){
538 $arrConditional[] = $conditional->getHashCode();
560 $explodes = explode(
':', $range);
563 $firstCell = $explodes[0];
566 if (count($explodes) == 1) {
567 $lastCell = $firstCell;
569 $lastCell = $explodes[1];
576 $firstCellCoordinates[1] - 1,
577 $lastCellCoordinates[1] - 1,
594 if (isset($this->_data)) {
611 $this->_print_headers = $print;
623 function setOutline($visible =
true, $symbols_below =
true, $symbols_right =
true, $auto_style =
false)
625 $this->_outline_on = $visible;
626 $this->_outline_below = $symbols_below;
627 $this->_outline_right = $symbols_right;
628 $this->_outline_style = $auto_style;
631 if ($this->_outline_on) {
632 $this->_outline_on = 1;
656 $data = pack(
"vvv",
$row, $col, $xfIndex);
657 $xl_double = pack(
"d", $num);
658 if (self::getByteOrder()) {
659 $xl_double = strrev($xl_double);
694 if (!isset($this->_str_table[$str])) {
695 $this->_str_table[$str] = $this->_str_unique++;
700 $data = pack(
'vvvV',
$row, $col, $xfIndex, $this->_str_table[$str]);
721 $strlen = strlen($str);
727 if ($strlen > $this->_xls_strmax) {
728 $str = substr($str, 0, $this->_xls_strmax);
735 $data = pack(
"vvvv",
$row, $col, $xfIndex, $strlen);
763 if (!isset($this->_str_table[$str])) {
764 $this->_str_table[$str] = $this->_str_unique++;
769 $data = pack(
'vvvV',
$row, $col, $xfIndex, $this->_str_table[$str]);
783 $note_length = strlen($note);
788 $length = 0x0006 + min($note_length, 2048);
790 $data = pack(
"vvv",
$row, $col, $note_length);
793 for ($i = $max_length; $i < $note_length; $i += $max_length) {
794 $chunk = substr($note, $i, $max_length);
795 $length = 0x0006 + strlen($chunk);
797 $data = pack(
"vvv", -1, 0, strlen($chunk));
825 $data = pack(
"vvv",
$row, $col, $xfIndex);
845 $data = pack(
"vvvCC",
$row, $col, $xfIndex, $value, $isError);
874 if (isset($calculatedValue)) {
877 if (is_bool($calculatedValue)) {
879 $num = pack(
'CCCvCv', 0x01, 0x00, (
int)$calculatedValue, 0x00, 0x00, 0xFFFF);
880 } elseif (is_int($calculatedValue) || is_float($calculatedValue)) {
882 $num = pack(
'd', $calculatedValue);
883 } elseif (is_string($calculatedValue)) {
886 $num = pack(
'CCCvCv', 0x02, 0x00, self::_mapErrorCode($calculatedValue), 0x00, 0x00, 0xFFFF);
887 } elseif ($calculatedValue ===
'') {
889 $num = pack(
'CCCvCv', 0x03, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
892 $stringValue = $calculatedValue;
893 $num = pack(
'CCCvCv', 0x00, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
897 $num = pack(
'd', 0x00);
900 $num = pack(
'd', 0x00);
907 if ($formula{0} ==
'=') {
908 $formula = substr($formula,1);
917 $error = $this->_parser->parse($formula);
918 $formula = $this->_parser->toReversePolish();
920 $formlen = strlen($formula);
925 $data = pack(
"vvv",
$row, $col, $xfIndex)
927 . pack(
"vVv", $grbit, $unknown, $formlen);
931 if ($stringValue !== null) {
1003 if (preg_match(
'[^internal:]',
$url)) {
1006 if (preg_match(
'[^external:]',
$url)) {
1032 $unknown1 = pack(
"H*",
"D0C9EA79F9BACE118C8200AA004BA90B02000000");
1033 $unknown2 = pack(
"H*",
"E0C9EA79F9BACE118C8200AA004BA90B");
1039 $url = join(
"\0", preg_split(
"''",
$url, -1, PREG_SPLIT_NO_EMPTY));
1043 $url_len = pack(
"V", strlen(
$url));
1050 $data = pack(
"vvvv", $row1, $row2, $col1, $col2);
1077 $url = preg_replace(
'/^internal:/',
'',
$url);
1080 $unknown1 = pack(
"H*",
"D0C9EA79F9BACE118C8200AA004BA90B02000000");
1090 $url_len = pack(
'V', $url_len);
1099 $data = pack(
"vvvv", $row1, $row2, $col1, $col2);
1138 $url = preg_replace(
'/\//',
"\\",
$url);
1146 if ( preg_match(
'/^[A-Z]:/',
$url) ) {
1155 if (preg_match(
"/\#/",
$url)) {
1179 $unknown1 = pack(
"H*",
'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
1181 $unknown3 = pack(
"H*",
'FFFFADDE000000000000000000000000000000000000000');
1185 $data = pack(
"vvvv", $row1, $row2, $col1, $col2) .
1219 private function _writeRow(
$row, $height, $xfIndex, $hidden =
false, $level = 0)
1236 if ($height != null) {
1237 $miyRw = $height * 20;
1252 if ($height !== null) {
1255 if ($xfIndex !== 0xF) {
1261 $data = pack(
"vvvvvvvv",
$row, $colMic, $colMac, $miyRw,
1262 $irwMac,$reserved, $grbit, $ixfe);
1274 $data = pack(
'VVvvv' 1275 , $this->_firstRowIndex
1276 , $this->_lastRowIndex + 1
1277 , $this->_firstColumnIndex
1278 , $this->_lastColumnIndex + 1
1301 $fDspGrid = $this->_phpSheet->getShowGridlines() ? 1 : 0;
1302 $fDspRwCol = $this->_phpSheet->getShowRowColHeaders() ? 1 : 0;
1303 $fFrozen = $this->_phpSheet->getFreezePane() ? 1 : 0;
1306 $fArabic = $this->_phpSheet->getRightToLeft() ? 1 : 0;
1308 $fFrozenNoSplit = 0;
1310 $fSelected = ($this->_phpSheet === $this->_phpSheet->getParent()->getActiveSheet()) ? 1 : 0;
1315 $grbit |= $fDspGrid << 1;
1316 $grbit |= $fDspRwCol << 2;
1317 $grbit |= $fFrozen << 3;
1318 $grbit |= $fDspZeros << 4;
1319 $grbit |= $fDefaultHdr << 5;
1320 $grbit |= $fArabic << 6;
1321 $grbit |= $fDspGuts << 7;
1322 $grbit |= $fFrozenNoSplit << 8;
1323 $grbit |= $fSelected << 9;
1324 $grbit |= $fPaged << 10;
1325 $grbit |= $fPageBreakPreview << 11;
1328 $data = pack(
"vvv", $grbit, $rwTop, $colLeft);
1332 $zoom_factor_page_break = ($fPageBreakPreview? $this->_phpSheet->getSheetView()->getZoomScale() : 0x0000);
1333 $zoom_factor_normal = $this->_phpSheet->getSheetView()->getZoomScaleNormal();
1335 $data .= pack(
"vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000);
1345 $defaultRowHeight = $this->_phpSheet->getDefaultRowDimension()->getRowHeight();
1347 if ($defaultRowHeight < 0) {
1352 $defaultRowHeight = (int) 20 * $defaultRowHeight;
1358 $data = pack(
"vv", 1, $defaultRowHeight);
1367 $defaultColWidth = 8;
1373 $data = pack(
"v", $defaultColWidth);
1393 if (isset($col_array[0])) {
1394 $colFirst = $col_array[0];
1396 if (isset($col_array[1])) {
1397 $colLast = $col_array[1];
1399 if (isset($col_array[2])) {
1400 $coldx = $col_array[2];
1404 if (isset($col_array[3])) {
1405 $xfIndex = $col_array[3];
1409 if (isset($col_array[4])) {
1410 $grbit = $col_array[4];
1414 if (isset($col_array[5])) {
1415 $level = $col_array[5];
1427 $level = max(0, min($level, 7));
1428 $grbit |= $level << 8;
1431 $data = pack(
"vvvvvv", $colFirst, $colLast, $coldx,
1432 $ixfe, $grbit, $reserved);
1442 $selectedCells = $this->_phpSheet->getSelectedCells();
1444 $selectedCells = $selectedCells[0];
1445 if (count($selectedCells) == 2) {
1446 list($first, $last) = $selectedCells;
1448 $first = $selectedCells[0];
1449 $last = $selectedCells[0];
1461 $colFirst = min($colFirst, 255);
1462 $colLast = min($colLast, 255);
1464 $rwFirst = min($rwFirst, 65535);
1465 $rwLast = min($rwLast, 65535);
1472 $colAct = $colFirst;
1476 if (!isset($rwLast)) {
1479 if (!isset($colLast)) {
1480 $colLast = $colFirst;
1484 if ($rwFirst > $rwLast) {
1485 list($rwFirst, $rwLast) =
array($rwLast, $rwFirst);
1488 if ($colFirst > $colLast) {
1489 list($colFirst, $colLast) =
array($colLast, $colFirst);
1493 $data = pack(
"CvvvvvvCC", $pnn, $rwAct, $colAct,
1496 $colFirst, $colLast);
1505 $mergeCells = $this->_phpSheet->getMergeCells();
1506 $countMergeCells = count($mergeCells);
1508 if ($countMergeCells == 0) {
1513 $maxCountMergeCellsPerRecord = 1027;
1528 foreach ($mergeCells as $mergeCell) {
1534 list($first, $last) = $range[0];
1541 if ($j == $maxCountMergeCellsPerRecord
or $i == $countMergeCells) {
1542 $recordData = pack(
'v', $j) . $recordData;
1543 $length = strlen($recordData);
1559 if (!$this->_phpSheet->isTabColorSet()) {
1570 , $this->_colors[$this->_phpSheet->getTabColor()->getRGB()]
1574 $length = strlen($recordData);
1590 $options = (int) !$this->_phpSheet->getProtection()->getObjects()
1591 | (int) !$this->_phpSheet->getProtection()->getScenarios() << 1
1592 | (int) !$this->_phpSheet->getProtection()->getFormatCells() << 2
1593 | (int) !$this->_phpSheet->getProtection()->getFormatColumns() << 3
1594 | (int) !$this->_phpSheet->getProtection()->getFormatRows() << 4
1595 | (int) !$this->_phpSheet->getProtection()->getInsertColumns() << 5
1596 | (int) !$this->_phpSheet->getProtection()->getInsertRows() << 6
1597 | (int) !$this->_phpSheet->getProtection()->getInsertHyperlinks() << 7
1598 | (int) !$this->_phpSheet->getProtection()->getDeleteColumns() << 8
1599 | (int) !$this->_phpSheet->getProtection()->getDeleteRows() << 9
1600 | (int) !$this->_phpSheet->getProtection()->getSelectLockedCells() << 10
1601 | (int) !$this->_phpSheet->getProtection()->getSort() << 11
1602 | (int) !$this->_phpSheet->getProtection()->getAutoFilter() << 12
1603 | (int) !$this->_phpSheet->getProtection()->getPivotTables() << 13
1604 | (int) !$this->_phpSheet->getProtection()->getSelectUnlockedCells() << 14 ;
1619 $length = strlen($recordData);
1633 foreach ($this->_phpSheet->getProtectedCells() as $range => $password) {
1635 $cellRanges = explode(
' ', $range);
1636 $cref = count($cellRanges);
1652 foreach ($cellRanges as $cellRange) {
1657 $recordData .= pack(
1665 $length = strlen($recordData);
1691 $data = pack(
"v", $count);
1710 if ($this->_phpSheet->getTitle() == $sheetname) {
1716 $length = 0x02 + strlen($sheetname);
1717 $cch = strlen($sheetname);
1722 $data = pack(
"CC", $cch, $rgch);
1735 if ($freezePane = $this->_phpSheet->getFreezePane()) {
1737 $panes[0] =
$row - 1;
1744 $y = isset($panes[0]) ? $panes[0] : null;
1745 $x = isset($panes[1]) ? $panes[1] : null;
1746 $rwTop = isset($panes[2]) ? $panes[2] : null;
1747 $colLeft = isset($panes[3]) ? $panes[3] : null;
1748 if (count($panes) > 4) {
1749 $pnnAct = $panes[4];
1757 if ($this->_phpSheet->getFreezePane()) {
1759 if (!isset($rwTop)) {
1762 if (!isset($colLeft)) {
1767 if (!isset($rwTop)) {
1770 if (!isset($colLeft)) {
1780 $x = 113.879*
$x + 390;
1787 if (!isset($pnnAct)) {
1788 if (
$x != 0 &&
$y != 0) {
1791 if (
$x != 0 &&
$y == 0) {
1794 if (
$x == 0 &&
$y != 0) {
1797 if (
$x == 0 &&
$y == 0) {
1802 $this->_active_pane = $pnnAct;
1805 $data = pack(
"vvvvv",
$x,
$y, $rwTop, $colLeft, $pnnAct);
1817 $iPaperSize = $this->_phpSheet->getPageSetup()->getPaperSize();
1819 $iScale = $this->_phpSheet->getPageSetup()->getScale() ?
1820 $this->_phpSheet->getPageSetup()->getScale() : 100;
1823 $iFitWidth = (int) $this->_phpSheet->getPageSetup()->getFitToWidth();
1824 $iFitHeight = (int) $this->_phpSheet->getPageSetup()->getFitToHeight();
1829 $numHdr = $this->_phpSheet->getPageMargins()->getHeader();
1831 $numFtr = $this->_phpSheet->getPageMargins()->getFooter();
1834 $fLeftToRight = 0x0;
1847 $grbit = $fLeftToRight;
1848 $grbit |= $fLandscape << 1;
1849 $grbit |= $fNoPls << 2;
1850 $grbit |= $fNoColor << 3;
1851 $grbit |= $fDraft << 4;
1852 $grbit |= $fNotes << 5;
1853 $grbit |= $fNoOrient << 6;
1854 $grbit |= $fUsePage << 7;
1856 $numHdr = pack(
"d", $numHdr);
1857 $numFtr = pack(
"d", $numFtr);
1858 if (self::getByteOrder()) {
1859 $numHdr = strrev($numHdr);
1860 $numFtr = strrev($numFtr);
1864 $data1 = pack(
"vvvvvvvv", $iPaperSize,
1872 $data2 = $numHdr.$numFtr;
1873 $data3 = pack(
"v", $iCopies);
1894 $length = strlen($recordData);
1918 $length = strlen($recordData);
1935 $fHCenter = $this->_phpSheet->getPageSetup()->getHorizontalCentered() ? 1 : 0;
1938 $data = pack(
"v", $fHCenter);
1951 $fVCenter = $this->_phpSheet->getPageSetup()->getVerticalCentered() ? 1 : 0;
1954 $data = pack(
"v", $fVCenter);
1966 $margin = $this->_phpSheet->getPageMargins()->getLeft();
1969 $data = pack(
"d", $margin);
1970 if (self::getByteOrder()) {
1985 $margin = $this->_phpSheet->getPageMargins()->getRight();
1988 $data = pack(
"d", $margin);
1989 if (self::getByteOrder()) {
2004 $margin = $this->_phpSheet->getPageMargins()->getTop();
2007 $data = pack(
"d", $margin);
2008 if (self::getByteOrder()) {
2023 $margin = $this->_phpSheet->getPageMargins()->getBottom();
2026 $data = pack(
"d", $margin);
2027 if (self::getByteOrder()) {
2042 $fPrintRwCol = $this->_print_headers;
2045 $data = pack(
"v", $fPrintRwCol);
2058 $fPrintGrid = $this->_phpSheet->getPrintGridlines() ? 1 : 0;
2061 $data = pack(
"v", $fPrintGrid);
2074 $fGridSet = !$this->_phpSheet->getPrintGridlines();
2077 $data = pack(
"v", $fGridSet);
2089 $iNumFilters = 1 + $rangeBounds[1][0] - $rangeBounds[0][0];
2092 $data = pack(
"v", $iNumFilters);
2112 $maxRowOutlineLevel = 0;
2113 foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
2114 $maxRowOutlineLevel = max($maxRowOutlineLevel, $rowDimension->getOutlineLevel());
2121 $colcount = count($this->_colinfo);
2122 for ($i = 0; $i < $colcount; ++$i) {
2123 $col_level = max($this->_colinfo[$i][5], $col_level);
2127 $col_level = max(0, min($col_level, 7));
2130 if ($maxRowOutlineLevel) {
2131 ++$maxRowOutlineLevel;
2138 $data = pack(
"vvvv", $dxRwGut, $dxColGut, $maxRowOutlineLevel, $col_level);
2158 if ($this->_outline_style) {
2161 if ($this->_phpSheet->getShowSummaryBelow()) {
2164 if ($this->_phpSheet->getShowSummaryRight()) {
2167 if ($this->_phpSheet->getPageSetup()->getFitToPage()) {
2170 if ($this->_outline_on) {
2175 $data = pack(
"v", $grbit);
2188 foreach ($this->_phpSheet->getBreaks() as $cell => $breakType) {
2193 switch ($breakType) {
2201 $hbreaks[] = $coordinates[1];
2212 if (!empty($hbreaks)) {
2215 sort($hbreaks, SORT_NUMERIC);
2216 if ($hbreaks[0] == 0) {
2217 array_shift($hbreaks);
2221 $cbrk = count($hbreaks);
2225 $data = pack(
"v", $cbrk);
2228 foreach ($hbreaks as $hbreak) {
2229 $data .= pack(
"vvv", $hbreak, 0x0000, 0x00ff);
2236 if (!empty($vbreaks)) {
2240 $vbreaks = array_slice($vbreaks, 0, 1000);
2243 sort($vbreaks, SORT_NUMERIC);
2244 if ($vbreaks[0] == 0) {
2245 array_shift($vbreaks);
2249 $cbrk = count($vbreaks);
2253 $data = pack(
"v", $cbrk);
2256 foreach ($vbreaks as $vbreak) {
2257 $data .= pack(
"vvv", $vbreak, 0x0000, 0xffff);
2270 if (!$this->_phpSheet->getProtection()->getSheet()) {
2280 $data = pack(
"v", $fLock);
2291 if (!$this->_phpSheet->getProtection()->getSheet()) {
2296 if (!$this->_phpSheet->getProtection()->getScenarios()) {
2304 $data = pack(
'v', 1);
2315 if (!$this->_phpSheet->getProtection()->getSheet()) {
2320 if (!$this->_phpSheet->getProtection()->getObjects()) {
2328 $data = pack(
'v', 1);
2339 if (!$this->_phpSheet->getProtection()->getSheet() || !$this->_phpSheet->getProtection()->getPassword()) {
2346 $wPassword = hexdec($this->_phpSheet->getProtection()->getPassword());
2349 $data = pack(
"v", $wPassword);
2369 list($width, $height,
$size,
$data) = $bitmap_array;
2373 $height *= $scale_y;
2443 $col_end = $col_start;
2444 $row_end = $row_start;
2454 $width = $width + $x1 -1;
2455 $height = $height + $y1 -1;
2521 $Reserved1 = 0x0000;
2522 $Reserved2 = 0x0000;
2534 $Reserved3 = 0x0000;
2535 $cbPictFmla = 0x0000;
2536 $Reserved4 = 0x0000;
2538 $Reserved5 = 0x0000;
2542 $data = pack(
"V", $cObj);
2543 $data .= pack(
"v", $OT);
2544 $data .= pack(
"v", $id);
2545 $data .= pack(
"v", $grbit);
2546 $data .= pack(
"v", $colL);
2547 $data .= pack(
"v", $dxL);
2548 $data .= pack(
"v", $rwT);
2549 $data .= pack(
"v", $dyT);
2550 $data .= pack(
"v", $colR);
2551 $data .= pack(
"v", $dxR);
2552 $data .= pack(
"v", $rwB);
2553 $data .= pack(
"v", $dyB);
2554 $data .= pack(
"v", $cbMacro);
2555 $data .= pack(
"V", $Reserved1);
2556 $data .= pack(
"v", $Reserved2);
2557 $data .= pack(
"C", $icvBack);
2558 $data .= pack(
"C", $icvFore);
2559 $data .= pack(
"C", $fls);
2560 $data .= pack(
"C", $fAuto);
2561 $data .= pack(
"C", $icv);
2562 $data .= pack(
"C", $lns);
2563 $data .= pack(
"C", $lnw);
2564 $data .= pack(
"C", $fAutoB);
2565 $data .= pack(
"v", $frs);
2566 $data .= pack(
"V", $cf);
2567 $data .= pack(
"v", $Reserved3);
2568 $data .= pack(
"v", $cbPictFmla);
2569 $data .= pack(
"v", $Reserved4);
2570 $data .= pack(
"v", $grbit2);
2571 $data .= pack(
"V", $Reserved5);
2584 $width = imagesx($image);
2585 $height = imagesy($image);
2587 $data = pack(
"Vvvvv", 0x000c, $width, $height, 0x01, 0x18);
2588 for ($j=$height; $j--; ) {
2589 for ($i=0; $i < $width; ++$i) {
2590 $color = imagecolorsforindex($image, imagecolorat($image, $i, $j));
2591 foreach (
array(
"red",
"green",
"blue") as $key) {
2592 $color[$key] = $color[$key] + round((255 - $color[$key]) * $color[
"alpha"] / 127);
2594 $data .= chr($color[
"blue"]) . chr($color[
"green"]) . chr($color[
"red"]);
2597 $data .= str_repeat(
"\x00", 4 - 3*$width % 4);
2616 $bmp_fd = @fopen($bitmap,
"rb");
2622 $data = fread($bmp_fd, filesize($bitmap));
2625 if (strlen(
$data) <= 0x36) {
2630 $identity = unpack(
"A2ident",
$data);
2631 if ($identity[
'ident'] !=
"BM") {
2641 $size_array = unpack(
"Vsa", substr(
$data, 0, 4));
2642 $size = $size_array[
'sa'];
2651 $width_and_height = unpack(
"V2", substr(
$data, 0, 8));
2652 $width = $width_and_height[1];
2653 $height = $width_and_height[2];
2655 if ($width > 0xFFFF) {
2658 if ($height > 0xFFFF) {
2663 $planes_and_bitcount = unpack(
"v2", substr(
$data, 0, 4));
2665 if ($planes_and_bitcount[2] != 24) {
2668 if ($planes_and_bitcount[1] != 1) {
2673 $compression = unpack(
"Vcomp", substr(
$data, 0, 4));
2677 if ($compression[
'comp'] != 0) {
2685 $header = pack(
"Vvvvv", 0x000c, $width, $height, 0x01, 0x18);
2698 if ($this->_phpSheet->getSheetView()->getZoomScale() == 100) {
2706 $data = pack(
"vv", $this->_phpSheet->getSheetView()->getZoomScale(), 100);
2727 $this->_escher = $pValue;
2736 if (isset($this->_escher)) {
2738 $data = $writer->close();
2739 $spOffsets = $writer->getSpOffsets();
2740 $spTypes = $writer->getSpTypes();
2745 $nm = count($spOffsets) - 1;
2746 for ($i = 1; $i <= $nm; ++$i) {
2751 $dataChunk = substr(
$data, $spOffsets[$i -1], $spOffsets[$i] - $spOffsets[$i - 1]);
2763 if($spTypes[$i] == 0x00C9){
2778 $objData .= pack(
'vv', 0x00C, 0x0014);
2779 $objData .= pack(
'H*',
'0000000000000000640001000A00000010000100');
2781 $objData .= pack(
'vv', 0x0013, 0x1FEE);
2782 $objData .= pack(
'H*',
'00000000010001030000020008005700');
2819 $dataValidationCollection = $this->_phpSheet->getDataValidationCollection();
2822 if (!empty($dataValidationCollection)) {
2829 $horPos = 0x00000000;
2830 $verPos = 0x00000000;
2831 $objId = 0xFFFFFFFF;
2834 $data = pack(
'vVVVV', $grbit, $horPos, $verPos, $objId,
2835 count($dataValidationCollection));
2841 foreach ($dataValidationCollection as $cellCoordinate => $dataValidation) {
2849 $type = $dataValidation->getType();
2863 $errorStyle = $dataValidation->getType();
2864 switch ($errorStyle) {
2872 if ($type == 0x03 && preg_match(
'/^\".*\"$/', $dataValidation->getFormula1())) {
2877 $options |= $dataValidation->getAllowBlank() << 8;
2880 $options |= (!$dataValidation->getShowDropDown()) << 9;
2883 $options |= $dataValidation->getShowInputMessage() << 18;
2886 $options |= $dataValidation->getShowErrorMessage() << 19;
2889 $operator = $dataValidation->getOperator();
2890 switch ($operator) {
2905 $promptTitle = $dataValidation->getPromptTitle() !==
'' ?
2906 $dataValidation->getPromptTitle() : chr(0);
2910 $errorTitle = $dataValidation->getErrorTitle() !==
'' ?
2911 $dataValidation->getErrorTitle() : chr(0);
2915 $prompt = $dataValidation->getPrompt() !==
'' ?
2916 $dataValidation->getPrompt() : chr(0);
2920 $error = $dataValidation->getError() !==
'' ?
2921 $dataValidation->getError() : chr(0);
2926 $formula1 = $dataValidation->getFormula1();
2927 if ($type == 0x03) {
2928 $formula1 = str_replace(
',', chr(0), $formula1);
2930 $this->_parser->parse($formula1);
2931 $formula1 = $this->_parser->toReversePolish();
2932 $sz1 = strlen($formula1);
2938 $data .= pack(
'vv', $sz1, 0x0000);
2943 $formula2 = $dataValidation->getFormula2();
2944 if ($formula2 ===
'') {
2947 $this->_parser->parse($formula2);
2948 $formula2 = $this->_parser->toReversePolish();
2949 $sz2 = strlen($formula2);
2955 $data .= pack(
'vv', $sz2, 0x0000);
2959 $data .= pack(
'v', 0x0001);
2977 switch ($errorCode) {
2978 case '#NULL!':
return 0x00;
2979 case '#DIV/0!':
return 0x07;
2980 case '#VALUE!':
return 0x0F;
2981 case '#REF!':
return 0x17;
2982 case '#NAME?':
return 0x1D;
2983 case '#NUM!':
return 0x24;
2984 case '#N/A':
return 0x2A;
2999 $reserved = 0x0000000000000000;
3000 $wScalvePLV = $this->_phpSheet->getSheetView()->getZoomScale();
3004 $fPageLayoutView = 1;
3006 $fPageLayoutView = 0;
3009 $fWhitespaceHidden = 0;
3011 $grbit = $fPageLayoutView;
3012 $grbit |= $fRulerVisible << 1;
3013 $grbit |= $fWhitespaceHidden << 3;
3016 $data = pack(
"vvVVvv", $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit);
3031 $operatorType = 0x00;
3037 $operatorType = 0x00;
3040 $operatorType = 0x03;
3043 $operatorType = 0x05;
3046 $operatorType = 0x07;
3049 $operatorType = 0x06;
3052 $operatorType = 0x08;
3055 $operatorType = 0x04;
3058 $operatorType = 0x01;
3067 $numConditions =
sizeof($arrConditions);
3068 if($numConditions == 1){
3069 $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000);
3071 $operand1 = pack(
'Cv', 0x1E, $arrConditions[0]);
3074 $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000);
3075 $szValue2 = ($arrConditions[1] <= 65535 ? 3 : 0x0000);
3076 $operand1 = pack(
'Cv', 0x1E, $arrConditions[0]);
3077 $operand2 = pack(
'Cv', 0x1E, $arrConditions[1]);
3087 $bAlignHz = ($conditional->
getStyle()->getAlignment()->getHorizontal() == null ? 1 : 0);
3088 $bAlignVt = ($conditional->
getStyle()->getAlignment()->getVertical() == null ? 1 : 0);
3089 $bAlignWrapTx = ($conditional->
getStyle()->getAlignment()->getWrapText() ==
false ? 1 : 0);
3090 $bTxRotation = ($conditional->
getStyle()->getAlignment()->getTextRotation() == null ? 1 : 0);
3091 $bIndent = ($conditional->
getStyle()->getAlignment()->getIndent() == 0 ? 1 : 0);
3092 $bShrinkToFit = ($conditional->
getStyle()->getAlignment()->getShrinkToFit() ==
false ? 1 : 0);
3093 if($bAlignHz == 0 || $bAlignVt == 0 || $bAlignWrapTx == 0 || $bTxRotation == 0 || $bIndent == 0 || $bShrinkToFit == 0){
3099 $bProtLocked = ($conditional->
getStyle()->getProtection()->getLocked() == null ? 1 : 0);
3100 $bProtHidden = ($conditional->
getStyle()->getProtection()->getHidden() == null ? 1 : 0);
3101 if($bProtLocked == 0 || $bProtHidden == 0){
3115 if($bBorderLeft == 0 || $bBorderRight == 0 || $bBorderTop == 0 || $bBorderBottom == 0){
3121 $bFillStyle = ($conditional->
getStyle()->getFill()->getFillType() == null ? 0 : 1);
3122 $bFillColor = ($conditional->
getStyle()->getFill()->getStartColor()->getARGB() == null ? 0 : 1);
3123 $bFillColorBg = ($conditional->
getStyle()->getFill()->getEndColor()->getARGB() == null ? 0 : 1);
3124 if($bFillStyle == 0 || $bFillColor == 0 || $bFillColorBg == 0){
3130 if($conditional->
getStyle()->getFont()->getName() != null
3131 || $conditional->
getStyle()->getFont()->getSize() != null
3132 || $conditional->
getStyle()->getFont()->getBold() != null
3133 || $conditional->
getStyle()->getFont()->getItalic() != null
3134 || $conditional->
getStyle()->getFont()->getSuperScript() != null
3135 || $conditional->
getStyle()->getFont()->getSubScript() != null
3136 || $conditional->
getStyle()->getFont()->getUnderline() != null
3137 || $conditional->
getStyle()->getFont()->getStrikethrough() != null
3138 || $conditional->
getStyle()->getFont()->getColor()->getARGB() != null){
3145 $flags |= (1 == $bAlignHz ? 0x00000001 : 0);
3146 $flags |= (1 == $bAlignVt ? 0x00000002 : 0);
3147 $flags |= (1 == $bAlignWrapTx ? 0x00000004 : 0);
3148 $flags |= (1 == $bTxRotation ? 0x00000008 : 0);
3150 $flags |= (1 == 1 ? 0x00000010 : 0);
3151 $flags |= (1 == $bIndent ? 0x00000020 : 0);
3152 $flags |= (1 == $bShrinkToFit ? 0x00000040 : 0);
3154 $flags |= (1 == 1 ? 0x00000080 : 0);
3156 $flags |= (1 == $bProtLocked ? 0x00000100 : 0);
3157 $flags |= (1 == $bProtHidden ? 0x00000200 : 0);
3159 $flags |= (1 == $bBorderLeft ? 0x00000400 : 0);
3160 $flags |= (1 == $bBorderRight ? 0x00000800 : 0);
3161 $flags |= (1 == $bBorderTop ? 0x00001000 : 0);
3162 $flags |= (1 == $bBorderBottom ? 0x00002000 : 0);
3163 $flags |= (1 == 1 ? 0x00004000 : 0);
3164 $flags |= (1 == 1 ? 0x00008000 : 0);
3166 $flags |= (1 == $bFillStyle ? 0x00010000 : 0);
3167 $flags |= (1 == $bFillColor ? 0x00020000 : 0);
3168 $flags |= (1 == $bFillColorBg ? 0x00040000 : 0);
3169 $flags |= (1 == 1 ? 0x00380000 : 0);
3171 $flags |= (1 == $bFormatFont ? 0x04000000 : 0);
3173 $flags |= (1 == $bFormatAlign ? 0x08000000 : 0);
3175 $flags |= (1 == $bFormatBorder ? 0x10000000 : 0);
3177 $flags |= (1 == $bFormatFill ? 0x20000000 : 0);
3179 $flags |= (1 == $bFormatProt ? 0x40000000 : 0);
3181 $flags |= (1 == 0 ? 0x80000000 : 0);
3184 if($bFormatFont == 1){
3186 if($conditional->
getStyle()->getFont()->getName() == null){
3187 $dataBlockFont = pack(
'VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000);
3188 $dataBlockFont .= pack(
'VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000);
3193 if($conditional->
getStyle()->getFont()->getSize() == null){
3194 $dataBlockFont .= pack(
'V', 20 * 11);
3196 $dataBlockFont .= pack(
'V', 20 * $conditional->
getStyle()->getFont()->getSize());
3199 $dataBlockFont .= pack(
'V', 0);
3201 if($conditional->
getStyle()->getFont()->getBold() ==
true){
3202 $dataBlockFont .= pack(
'v', 0x02BC);
3204 $dataBlockFont .= pack(
'v', 0x0190);
3207 if($conditional->
getStyle()->getFont()->getSubScript() ==
true){
3208 $dataBlockFont .= pack(
'v', 0x02);
3209 $fontEscapement = 0;
3210 }
else if($conditional->
getStyle()->getFont()->getSuperScript() ==
true){
3211 $dataBlockFont .= pack(
'v', 0x01);
3212 $fontEscapement = 0;
3214 $dataBlockFont .= pack(
'v', 0x00);
3215 $fontEscapement = 1;
3218 switch ($conditional->
getStyle()->getFont()->getUnderline()){
3224 default : $dataBlockFont .= pack(
'C', 0x00); $fontUnderline = 1;
break;
3227 $dataBlockFont .= pack(
'vC', 0x0000, 0x00);
3229 switch ($conditional->
getStyle()->getFont()->getColor()->getRGB()) {
3230 case '000000': $colorIdx = 0x08;
break;
3231 case 'FFFFFF': $colorIdx = 0x09;
break;
3232 case 'FF0000': $colorIdx = 0x0A;
break;
3233 case '00FF00': $colorIdx = 0x0B;
break;
3234 case '0000FF': $colorIdx = 0x0C;
break;
3235 case 'FFFF00': $colorIdx = 0x0D;
break;
3236 case 'FF00FF': $colorIdx = 0x0E;
break;
3237 case '00FFFF': $colorIdx = 0x0F;
break;
3238 case '800000': $colorIdx = 0x10;
break;
3239 case '008000': $colorIdx = 0x11;
break;
3240 case '000080': $colorIdx = 0x12;
break;
3241 case '808000': $colorIdx = 0x13;
break;
3242 case '800080': $colorIdx = 0x14;
break;
3243 case '008080': $colorIdx = 0x15;
break;
3244 case 'C0C0C0': $colorIdx = 0x16;
break;
3245 case '808080': $colorIdx = 0x17;
break;
3246 case '9999FF': $colorIdx = 0x18;
break;
3247 case '993366': $colorIdx = 0x19;
break;
3248 case 'FFFFCC': $colorIdx = 0x1A;
break;
3249 case 'CCFFFF': $colorIdx = 0x1B;
break;
3250 case '660066': $colorIdx = 0x1C;
break;
3251 case 'FF8080': $colorIdx = 0x1D;
break;
3252 case '0066CC': $colorIdx = 0x1E;
break;
3253 case 'CCCCFF': $colorIdx = 0x1F;
break;
3254 case '000080': $colorIdx = 0x20;
break;
3255 case 'FF00FF': $colorIdx = 0x21;
break;
3256 case 'FFFF00': $colorIdx = 0x22;
break;
3257 case '00FFFF': $colorIdx = 0x23;
break;
3258 case '800080': $colorIdx = 0x24;
break;
3259 case '800000': $colorIdx = 0x25;
break;
3260 case '008080': $colorIdx = 0x26;
break;
3261 case '0000FF': $colorIdx = 0x27;
break;
3262 case '00CCFF': $colorIdx = 0x28;
break;
3263 case 'CCFFFF': $colorIdx = 0x29;
break;
3264 case 'CCFFCC': $colorIdx = 0x2A;
break;
3265 case 'FFFF99': $colorIdx = 0x2B;
break;
3266 case '99CCFF': $colorIdx = 0x2C;
break;
3267 case 'FF99CC': $colorIdx = 0x2D;
break;
3268 case 'CC99FF': $colorIdx = 0x2E;
break;
3269 case 'FFCC99': $colorIdx = 0x2F;
break;
3270 case '3366FF': $colorIdx = 0x30;
break;
3271 case '33CCCC': $colorIdx = 0x31;
break;
3272 case '99CC00': $colorIdx = 0x32;
break;
3273 case 'FFCC00': $colorIdx = 0x33;
break;
3274 case 'FF9900': $colorIdx = 0x34;
break;
3275 case 'FF6600': $colorIdx = 0x35;
break;
3276 case '666699': $colorIdx = 0x36;
break;
3277 case '969696': $colorIdx = 0x37;
break;
3278 case '003366': $colorIdx = 0x38;
break;
3279 case '339966': $colorIdx = 0x39;
break;
3280 case '003300': $colorIdx = 0x3A;
break;
3281 case '333300': $colorIdx = 0x3B;
break;
3282 case '993300': $colorIdx = 0x3C;
break;
3283 case '993366': $colorIdx = 0x3D;
break;
3284 case '333399': $colorIdx = 0x3E;
break;
3285 case '333333': $colorIdx = 0x3F;
break;
3286 default: $colorIdx = 0x00;
break;
3288 $dataBlockFont .= pack(
'V', $colorIdx);
3290 $dataBlockFont .= pack(
'V', 0x00000000);
3293 $optionsFlagsBold = ($conditional->
getStyle()->getFont()->getBold() == null ? 1 : 0);
3294 $optionsFlags |= (1 == $optionsFlagsBold ? 0x00000002 : 0);
3295 $optionsFlags |= (1 == 1 ? 0x00000008 : 0);
3296 $optionsFlags |= (1 == 1 ? 0x00000010 : 0);
3297 $optionsFlags |= (1 == 0 ? 0x00000020 : 0);
3298 $optionsFlags |= (1 == 1 ? 0x00000080 : 0);
3299 $dataBlockFont .= pack(
'V', $optionsFlags);
3301 $dataBlockFont .= pack(
'V', $fontEscapement);
3303 $dataBlockFont .= pack(
'V', $fontUnderline);
3305 $dataBlockFont .= pack(
'V', 0x00000000);
3307 $dataBlockFont .= pack(
'V', 0x00000000);
3309 $dataBlockFont .= pack(
'VV', 0x00000000, 0x00000000);
3311 $dataBlockFont .= pack(
'v', 0x0001);
3313 if($bFormatAlign == 1){
3316 switch ($conditional->
getStyle()->getAlignment()->getHorizontal()){
3324 if($conditional->
getStyle()->getAlignment()->getWrapText() ==
true){
3325 $blockAlign |= 1 << 3;
3327 $blockAlign |= 0 << 3;
3329 switch ($conditional->
getStyle()->getAlignment()->getVertical()){
3335 $blockAlign |= 0 << 7;
3338 $blockRotation = $conditional->
getStyle()->getAlignment()->getTextRotation();
3341 $blockIndent = $conditional->
getStyle()->getAlignment()->getIndent();
3342 if($conditional->
getStyle()->getAlignment()->getShrinkToFit() ==
true){
3343 $blockIndent |= 1 << 4;
3345 $blockIndent |= 0 << 4;
3347 $blockIndent |= 0 << 6;
3350 $blockIndentRelative = 255;
3352 $dataBlockAlign = pack(
'CCvvv', $blockAlign, $blockRotation, $blockIndent, $blockIndentRelative, 0x0000);
3354 if($bFormatBorder == 1){
3355 $blockLineStyle = 0;
3356 switch ($conditional->
getStyle()->getBorders()->getLeft()->getBorderStyle()){
3372 switch ($conditional->
getStyle()->getBorders()->getRight()->getBorderStyle()){
3388 switch ($conditional->
getStyle()->getBorders()->getTop()->getBorderStyle()){
3404 switch ($conditional->
getStyle()->getBorders()->getBottom()->getBorderStyle()){
3428 switch ($conditional->
getStyle()->getBorders()->getDiagonal()->getBorderStyle()){
3444 $dataBlockBorder = pack(
'vv', $blockLineStyle, $blockColor);
3446 if($bFormatFill == 1){
3448 $blockFillPatternStyle = 0;
3449 switch ($conditional->
getStyle()->getFill()->getFillType()){
3471 default : $blockFillPatternStyle = 0x00;
break;
3474 switch ($conditional->
getStyle()->getFill()->getStartColor()->getRGB()) {
3475 case '000000': $colorIdxBg = 0x08;
break;
3476 case 'FFFFFF': $colorIdxBg = 0x09;
break;
3477 case 'FF0000': $colorIdxBg = 0x0A;
break;
3478 case '00FF00': $colorIdxBg = 0x0B;
break;
3479 case '0000FF': $colorIdxBg = 0x0C;
break;
3480 case 'FFFF00': $colorIdxBg = 0x0D;
break;
3481 case 'FF00FF': $colorIdxBg = 0x0E;
break;
3482 case '00FFFF': $colorIdxBg = 0x0F;
break;
3483 case '800000': $colorIdxBg = 0x10;
break;
3484 case '008000': $colorIdxBg = 0x11;
break;
3485 case '000080': $colorIdxBg = 0x12;
break;
3486 case '808000': $colorIdxBg = 0x13;
break;
3487 case '800080': $colorIdxBg = 0x14;
break;
3488 case '008080': $colorIdxBg = 0x15;
break;
3489 case 'C0C0C0': $colorIdxBg = 0x16;
break;
3490 case '808080': $colorIdxBg = 0x17;
break;
3491 case '9999FF': $colorIdxBg = 0x18;
break;
3492 case '993366': $colorIdxBg = 0x19;
break;
3493 case 'FFFFCC': $colorIdxBg = 0x1A;
break;
3494 case 'CCFFFF': $colorIdxBg = 0x1B;
break;
3495 case '660066': $colorIdxBg = 0x1C;
break;
3496 case 'FF8080': $colorIdxBg = 0x1D;
break;
3497 case '0066CC': $colorIdxBg = 0x1E;
break;
3498 case 'CCCCFF': $colorIdxBg = 0x1F;
break;
3499 case '000080': $colorIdxBg = 0x20;
break;
3500 case 'FF00FF': $colorIdxBg = 0x21;
break;
3501 case 'FFFF00': $colorIdxBg = 0x22;
break;
3502 case '00FFFF': $colorIdxBg = 0x23;
break;
3503 case '800080': $colorIdxBg = 0x24;
break;
3504 case '800000': $colorIdxBg = 0x25;
break;
3505 case '008080': $colorIdxBg = 0x26;
break;
3506 case '0000FF': $colorIdxBg = 0x27;
break;
3507 case '00CCFF': $colorIdxBg = 0x28;
break;
3508 case 'CCFFFF': $colorIdxBg = 0x29;
break;
3509 case 'CCFFCC': $colorIdxBg = 0x2A;
break;
3510 case 'FFFF99': $colorIdxBg = 0x2B;
break;
3511 case '99CCFF': $colorIdxBg = 0x2C;
break;
3512 case 'FF99CC': $colorIdxBg = 0x2D;
break;
3513 case 'CC99FF': $colorIdxBg = 0x2E;
break;
3514 case 'FFCC99': $colorIdxBg = 0x2F;
break;
3515 case '3366FF': $colorIdxBg = 0x30;
break;
3516 case '33CCCC': $colorIdxBg = 0x31;
break;
3517 case '99CC00': $colorIdxBg = 0x32;
break;
3518 case 'FFCC00': $colorIdxBg = 0x33;
break;
3519 case 'FF9900': $colorIdxBg = 0x34;
break;
3520 case 'FF6600': $colorIdxBg = 0x35;
break;
3521 case '666699': $colorIdxBg = 0x36;
break;
3522 case '969696': $colorIdxBg = 0x37;
break;
3523 case '003366': $colorIdxBg = 0x38;
break;
3524 case '339966': $colorIdxBg = 0x39;
break;
3525 case '003300': $colorIdxBg = 0x3A;
break;
3526 case '333300': $colorIdxBg = 0x3B;
break;
3527 case '993300': $colorIdxBg = 0x3C;
break;
3528 case '993366': $colorIdxBg = 0x3D;
break;
3529 case '333399': $colorIdxBg = 0x3E;
break;
3530 case '333333': $colorIdxBg = 0x3F;
break;
3531 default: $colorIdxBg = 0x41;
break;
3534 switch ($conditional->
getStyle()->getFill()->getEndColor()->getRGB()) {
3535 case '000000': $colorIdxFg = 0x08;
break;
3536 case 'FFFFFF': $colorIdxFg = 0x09;
break;
3537 case 'FF0000': $colorIdxFg = 0x0A;
break;
3538 case '00FF00': $colorIdxFg = 0x0B;
break;
3539 case '0000FF': $colorIdxFg = 0x0C;
break;
3540 case 'FFFF00': $colorIdxFg = 0x0D;
break;
3541 case 'FF00FF': $colorIdxFg = 0x0E;
break;
3542 case '00FFFF': $colorIdxFg = 0x0F;
break;
3543 case '800000': $colorIdxFg = 0x10;
break;
3544 case '008000': $colorIdxFg = 0x11;
break;
3545 case '000080': $colorIdxFg = 0x12;
break;
3546 case '808000': $colorIdxFg = 0x13;
break;
3547 case '800080': $colorIdxFg = 0x14;
break;
3548 case '008080': $colorIdxFg = 0x15;
break;
3549 case 'C0C0C0': $colorIdxFg = 0x16;
break;
3550 case '808080': $colorIdxFg = 0x17;
break;
3551 case '9999FF': $colorIdxFg = 0x18;
break;
3552 case '993366': $colorIdxFg = 0x19;
break;
3553 case 'FFFFCC': $colorIdxFg = 0x1A;
break;
3554 case 'CCFFFF': $colorIdxFg = 0x1B;
break;
3555 case '660066': $colorIdxFg = 0x1C;
break;
3556 case 'FF8080': $colorIdxFg = 0x1D;
break;
3557 case '0066CC': $colorIdxFg = 0x1E;
break;
3558 case 'CCCCFF': $colorIdxFg = 0x1F;
break;
3559 case '000080': $colorIdxFg = 0x20;
break;
3560 case 'FF00FF': $colorIdxFg = 0x21;
break;
3561 case 'FFFF00': $colorIdxFg = 0x22;
break;
3562 case '00FFFF': $colorIdxFg = 0x23;
break;
3563 case '800080': $colorIdxFg = 0x24;
break;
3564 case '800000': $colorIdxFg = 0x25;
break;
3565 case '008080': $colorIdxFg = 0x26;
break;
3566 case '0000FF': $colorIdxFg = 0x27;
break;
3567 case '00CCFF': $colorIdxFg = 0x28;
break;
3568 case 'CCFFFF': $colorIdxFg = 0x29;
break;
3569 case 'CCFFCC': $colorIdxFg = 0x2A;
break;
3570 case 'FFFF99': $colorIdxFg = 0x2B;
break;
3571 case '99CCFF': $colorIdxFg = 0x2C;
break;
3572 case 'FF99CC': $colorIdxFg = 0x2D;
break;
3573 case 'CC99FF': $colorIdxFg = 0x2E;
break;
3574 case 'FFCC99': $colorIdxFg = 0x2F;
break;
3575 case '3366FF': $colorIdxFg = 0x30;
break;
3576 case '33CCCC': $colorIdxFg = 0x31;
break;
3577 case '99CC00': $colorIdxFg = 0x32;
break;
3578 case 'FFCC00': $colorIdxFg = 0x33;
break;
3579 case 'FF9900': $colorIdxFg = 0x34;
break;
3580 case 'FF6600': $colorIdxFg = 0x35;
break;
3581 case '666699': $colorIdxFg = 0x36;
break;
3582 case '969696': $colorIdxFg = 0x37;
break;
3583 case '003366': $colorIdxFg = 0x38;
break;
3584 case '339966': $colorIdxFg = 0x39;
break;
3585 case '003300': $colorIdxFg = 0x3A;
break;
3586 case '333300': $colorIdxFg = 0x3B;
break;
3587 case '993300': $colorIdxFg = 0x3C;
break;
3588 case '993366': $colorIdxFg = 0x3D;
break;
3589 case '333399': $colorIdxFg = 0x3E;
break;
3590 case '333333': $colorIdxFg = 0x3F;
break;
3591 default: $colorIdxFg = 0x40;
break;
3593 $dataBlockFill = pack(
'v', $blockFillPatternStyle);
3594 $dataBlockFill .= pack(
'v', $colorIdxFg | ($colorIdxBg << 7));
3596 if($bFormatProt == 1){
3597 $dataBlockProtection = 0;
3599 $dataBlockProtection = 1;
3602 $dataBlockProtection = 1 << 1;
3606 $data = pack(
'CCvvVv', $type, $operatorType, $szValue1, $szValue2, $flags, 0x0000);
3607 if($bFormatFont == 1){
3608 $data .= $dataBlockFont;
3610 if($bFormatAlign == 1){
3611 $data .= $dataBlockAlign;
3613 if($bFormatBorder == 1){
3614 $data .= $dataBlockBorder;
3616 if($bFormatFill == 1){
3617 $data .= $dataBlockFill;
3619 if($bFormatProt == 1){
3620 $data .= $dataBlockProtection;
3622 if(!is_null($operand1)){
3625 if(!is_null($operand2)){
3639 $numColumnMin = null;
3640 $numColumnMax = null;
3643 $arrConditional =
array();
3644 foreach ($this->_phpSheet->getConditionalStylesCollection() as $cellCoordinate =>
$conditionalStyles) {
3648 if(!in_array($conditional->getHashCode(), $arrConditional)){
3649 $arrConditional[] = $conditional->getHashCode();
3653 if(!is_numeric($arrCoord[0])){
3656 if(is_null($numColumnMin) || ($numColumnMin > $arrCoord[0])){
3657 $numColumnMin = $arrCoord[0];
3659 if(is_null($numColumnMax) || ($numColumnMax < $arrCoord[0])){
3660 $numColumnMax = $arrCoord[0];
3662 if(is_null($numRowMin) || ($numRowMin > $arrCoord[1])){
3663 $numRowMin = $arrCoord[1];
3665 if(is_null($numRowMax) || ($numRowMax < $arrCoord[1])){
3666 $numRowMax = $arrCoord[1];
3672 $cellRange = pack(
'vvvv', $numRowMin-1, $numRowMax-1, $numColumnMin-1, $numColumnMax-1);
3675 $data = pack(
'vv', count($arrConditional), $needRedraw);
3676 $data .= $cellRange;
3677 $data .= pack(
'v', 0x0001);
3678 $data .= $cellRange;
getOperatorType()
Get Operator type.
_writeSheetProtection()
Write SHEETPROTECTION.
const FILL_PATTERN_LIGHTHORIZONTAL
__construct(&$str_total, &$str_unique, &$str_table, &$colors, $parser, $preCalculateFormulas, $phpSheet)
Constructor.
_writeRichTextString($row, $col, $str, $xfIndex, $arrcRun)
Write a LABELSST record or a LABEL record.
static splitRange($pRange='A1:A1')
Split range into coordinate strings.
static _mapErrorCode($errorCode)
Map Error code.
_writePanes()
Writes the Excel BIFF PANE record.
const FILL_PATTERN_LIGHTGRAY
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
_writeGuts()
Write the GUTS BIFF record.
_writeMsoDrawing()
Write MSODRAWING record.
_writeObjectProtect()
Write OBJECTPROTECT.
_append($data)
General storage function.
_writeWindow2()
Write BIFF record Window2.
_writeGridset()
Write the GRIDSET BIFF record.
_writeLabelSst($row, $col, $str, $xfIndex)
Write a string to the specified row and column (zero indexed).
const FILL_PATTERN_DARKGRID
const FILL_PATTERN_DARKHORIZONTAL
_writeDimensions()
Writes Excel DIMENSIONS to define the area in which there is data.
insertBitmap($row, $col, $bitmap, $x=0, $y=0, $scale_x=1, $scale_y=1)
Insert a 24bit bitmap image in a worksheet.
static UTF8toBIFF8UnicodeLong($value)
Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) Writes the string using...
_writeScenProtect()
Write SCENPROTECT.
_writePassword()
Write the worksheet PASSWORD record.
_writeExternsheet($sheetname)
Writes the Excel BIFF EXTERNSHEET record.
_writeSelection()
Write BIFF record SELECTION.
static ConvertEncoding($value, $to, $from)
Convert string from one encoding to another.
_writeBlank($row, $col, $xfIndex)
Write a blank cell to the specified row and column (zero indexed).
_writeExterncount($count)
Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in a worksheet...
_writeNote($row, $col, $note)
Writes a note associated with the cell given by the row and column.
const BORDER_MEDIUMDASHDOT
_processBitmap($bitmap)
Convert a 24 bit bitmap into the modified internal format used by Windows.
_writeMergedCells()
Store the MERGEDCELLS records for all ranges of merged cells.
static rangeBoundaries($pRange='A1:A1')
Calculate range boundaries.
_writeHeader()
Store the header caption BIFF record.
_writeHcenter()
Store the horizontal centering HCENTER BIFF record.
_writeString($row, $col, $str, $xfIndex)
Write a LABELSST record or a LABEL record.
_writeMarginTop()
Store the TOPMARGIN BIFF record.
_writePageLayoutView()
Write PLV Record.
_writeFooter()
Store the footer caption BIFF record.
_storeBof($type)
Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file...
_writePrintHeaders()
Write the PRINTHEADERS BIFF record.
_processBitmapGd($image)
Convert a GD-image into the internal format.
_writeUrlExternal($row1, $col1, $row2, $col2, $url)
Write links to external directory names such as 'c:.xls', c:.xls::Sheet1!A1', '../../foo.xls'.
const FILL_PATTERN_LIGHTTRELLIS
static sizeCol($sheet, $col='A')
Get the width of a column in pixels.
_writeProtect()
Set the Biff PROTECT record to indicate that the worksheet is protected.
const ORIENTATION_LANDSCAPE
const OPERATOR_GREATERTHANOREQUAL
getData()
Retrieves data from memory in one chunk, or from disk in $buffer sized chunks.
_writeUrlInternal($row1, $col1, $row2, $col2, $url)
Used to write internal reference hyperlinks such as "Sheet1!A1".
static UTF8toBIFF8UnicodeShort($value, $arrcRuns=array())
Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) Writes the string using ...
const OPERATOR_GREATERTHAN
if(!is_array($argv)) $options
_writeBreaks()
Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records.
const UNDERLINE_DOUBLEACCOUNTING
_writeRow($row, $height, $xfIndex, $hidden=false, $level=0)
This method is used to set the height and format for a row.
const HORIZONTAL_CENTER_CONTINUOUS
_writeMarginBottom()
Store the BOTTOMMARGIN BIFF record.
_writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB)
Store the OBJ record that precedes an IMDATA record.
const FILL_PATTERN_LIGHTDOWN
const OPERATOR_NOTBETWEEN
const FILL_PATTERN_MEDIUMGRAY
const OPERATOR_LESSTHANOREQUAL
const OPERATOR_GREATERTHAN
_writeColinfo($col_array)
Write BIFF record COLINFO to define column widths.
_writeRangeProtection()
Write BIFF record RANGEPROTECTION.
setEscher(PHPExcel_Shared_Escher $pValue=null)
Set Escher object.
if(preg_match('/^ $link_type[A-Z]:/', $url))
const FILL_PATTERN_DARKDOWN
_writeStringRecord($stringValue)
Write a STRING record.
const FILL_PATTERN_GRAY125
const FILL_PATTERN_DARKTRELLIS
const FILL_PATTERN_LIGHTVERTICAL
_writeBoolErr($row, $col, $value, $isError, $xfIndex)
Write a boolean or an error type to the specified row and column (zero indexed)
const UNDERLINE_SINGLEACCOUNTING
const BORDER_MEDIUMDASHDOTDOT
Create styles array
The data for the language used.
const SHEETVIEW_PAGE_LAYOUT
_writeDefcol()
Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
_writeMarginLeft()
Store the LEFTMARGIN BIFF record.
_writeBIFF8CellRangeAddressFixed($range='A1')
Write a cell range address in BIFF8 always fixed range See section 2.5.14 in OpenOffice.org's Documentation of the Microsoft Excel File Format.
_writeSheetLayout()
Write SHEETLAYOUT record.
static sizeRow($sheet, $row=1)
Convert the height of a cell from user's units to pixels.
const PROTECTION_PROTECTED
const FILL_PATTERN_GRAY0625
_writeDefaultRowHeight()
Write BIFF record DEFAULTROWHEIGHT.
const CONDITION_EXPRESSION
_writeVcenter()
Store the vertical centering VCENTER BIFF record.
_writeNumber($row, $col, $num, $xfIndex)
Write a double to the specified row and column (zero indexed).
getEscher()
Get Escher object.
const FILL_PATTERN_LIGHTGRID
static columnIndexFromString($pString='A')
Column index from string.
const OPERATOR_GREATERTHANOREQUAL
_writeCFHeader()
Write CFHeader record.
static getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, $pPixels=false)
Get the effective column width for columns without a column dimension or column with width -1 For exa...
_writeLabel($row, $col, $str, $xfIndex)
Write a string to the specified row and column (zero indexed).
const BORDER_SLANTDASHDOT
const OPERATOR_LESSTHANOREQUAL
_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...
const FILL_PATTERN_DARKVERTICAL
const SHEETVIEW_PAGE_BREAK_PREVIEW
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
static getErrorCodes()
Get list of error codes.
_writeUrlRange($row1, $col1, $row2, $col2, $url)
This is the more general form of _writeUrl().
const FILL_PATTERN_DARKGRAY
_writeUrlWeb($row1, $col1, $row2, $col2, $url)
Used to write http, ftp and mailto hyperlinks.
_writeWsbool()
Write the WSBOOL BIFF record, mainly for fit-to-page.
_storeEof()
Writes Excel EOF record to indicate the end of a BIFF stream.
_writeDataValidity()
Store the DATAVALIDATIONS and DATAVALIDATION records.
_writePrintGridlines()
Write the PRINTGRIDLINES BIFF record.
printRowColHeaders($print=1)
Set the option to print the row and column headers on the printed page.
const FILL_PATTERN_LIGHTUP
_writeCFRule(PHPExcel_Style_Conditional $conditional)
Write CFRule Record.
_writeFormula($row, $col, $formula, $xfIndex, $calculatedValue)
Write a formula to the specified row and column (zero indexed).
_writeUrl($row, $col, $url)
Write a hyperlink.
_writeZoom()
Store the window zoom factor.
const FILL_PATTERN_DARKUP
const BORDER_MEDIUMDASHED
static CountCharacters($value, $enc='UTF-8')
Get character count.
_writeMarginRight()
Store the RIGHTMARGIN BIFF record.
_writeSetup()
Store the page setup SETUP BIFF record.
getConditionType()
Get Condition type.
setOutline($visible=true, $symbols_below=true, $symbols_right=true, $auto_style=false)
This method sets the properties for outlining and grouping.
_writeAutoFilterInfo()
Write the AUTOFILTERINFO BIFF record.
const FILL_GRADIENT_LINEAR
close()
Add data to the beginning of the workbook (note the reverse order) and to the end of the workbook...
getConditions()
Get Conditions.