61 if (!defined(
'PHPEXCEL_ROOT')) {
65 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
66 require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php');
428 $this->_readDataOnly = $pValue;
455 $this->_loadSheetsOnly = is_array($value) ?
456 $value : array($value);
468 $this->_loadSheetsOnly = null;
488 $this->_readFilter = $pValue;
508 if (!file_exists($pFilename)) {
509 throw new Exception(
"Could not open " . $pFilename .
" for reading! File does not exist.");
517 $res = $ole->read($pFilename);
534 if (!file_exists($pFilename)) {
535 throw new Exception(
"Could not open " . $pFilename .
" for reading! File does not exist.");
538 $worksheetNames = array();
544 $this->_dataSize = strlen($this->_data);
547 $this->_sheets = array();
550 while ($this->_pos < $this->_dataSize) {
554 case self::XLS_Type_BOF: $this->
_readBof();
break;
555 case self::XLS_Type_SHEET: $this->
_readSheet();
break;
556 case self::XLS_Type_EOF: $this->
_readDefault();
break 2;
561 foreach ($this->_sheets as $sheet) {
562 if ($sheet[
'sheetType'] != 0x00) {
567 $worksheetNames[] = $sheet[
'name'];
570 return $worksheetNames;
581 public function load($pFilename)
589 if (!$this->_readDataOnly) {
590 $this->_phpExcel->removeCellStyleXfByIndex(0);
591 $this->_phpExcel->removeCellXfByIndex(0);
601 $this->_dataSize = strlen($this->_data);
605 $this->_codepage =
'CP1252';
606 $this->_formats = array();
607 $this->_objFonts = array();
608 $this->_palette = array();
609 $this->_sheets = array();
610 $this->_externalBooks = array();
611 $this->_ref = array();
612 $this->_definedname = array();
613 $this->_sst = array();
614 $this->_drawingGroupData =
'';
615 $this->_xfIndex =
'';
616 $this->_mapCellXfIndex = array();
617 $this->_mapCellStyleXfIndex = array();
620 while ($this->_pos < $this->_dataSize) {
624 case self::XLS_Type_BOF: $this->
_readBof();
break;
628 case self::XLS_Type_FONT: $this->
_readFont();
break;
629 case self::XLS_Type_FORMAT: $this->
_readFormat();
break;
630 case self::XLS_Type_XF: $this->
_readXf();
break;
631 case self::XLS_Type_XFEXT: $this->
_readXfExt();
break;
632 case self::XLS_Type_STYLE: $this->
_readStyle();
break;
633 case self::XLS_Type_PALETTE: $this->
_readPalette();
break;
634 case self::XLS_Type_SHEET: $this->
_readSheet();
break;
640 case self::XLS_Type_SST: $this->
_readSst();
break;
641 case self::XLS_Type_EOF: $this->
_readDefault();
break 2;
648 if (!$this->_readDataOnly) {
649 foreach ($this->_objFonts as $objFont) {
650 if (isset($objFont->colorIndex)) {
651 $color =
self::_readColor($objFont->colorIndex,$this->_palette,$this->_version);
652 $objFont->getColor()->setRGB($color[
'rgb']);
656 foreach ($this->_phpExcel->getCellXfCollection() as $objStyle) {
658 $fill = $objStyle->getFill();
660 if (isset($fill->startcolorIndex)) {
661 $startColor =
self::_readColor($fill->startcolorIndex,$this->_palette,$this->_version);
662 $fill->getStartColor()->setRGB($startColor[
'rgb']);
665 if (isset($fill->endcolorIndex)) {
666 $endColor =
self::_readColor($fill->endcolorIndex,$this->_palette,$this->_version);
667 $fill->getEndColor()->setRGB($endColor[
'rgb']);
671 $top = $objStyle->getBorders()->getTop();
672 $right = $objStyle->getBorders()->getRight();
673 $bottom = $objStyle->getBorders()->getBottom();
674 $left = $objStyle->getBorders()->getLeft();
675 $diagonal = $objStyle->getBorders()->getDiagonal();
677 if (isset($top->colorIndex)) {
678 $borderTopColor =
self::_readColor($top->colorIndex,$this->_palette,$this->_version);
679 $top->getColor()->setRGB($borderTopColor[
'rgb']);
682 if (isset($right->colorIndex)) {
683 $borderRightColor =
self::_readColor($right->colorIndex,$this->_palette,$this->_version);
684 $right->getColor()->setRGB($borderRightColor[
'rgb']);
687 if (isset($bottom->colorIndex)) {
688 $borderBottomColor =
self::_readColor($bottom->colorIndex,$this->_palette,$this->_version);
689 $bottom->getColor()->setRGB($borderBottomColor[
'rgb']);
692 if (isset($left->colorIndex)) {
693 $borderLeftColor =
self::_readColor($left->colorIndex,$this->_palette,$this->_version);
694 $left->getColor()->setRGB($borderLeftColor[
'rgb']);
697 if (isset($diagonal->colorIndex)) {
698 $borderDiagonalColor =
self::_readColor($diagonal->colorIndex,$this->_palette,$this->_version);
699 $diagonal->getColor()->setRGB($borderDiagonalColor[
'rgb']);
705 if (!$this->_readDataOnly && $this->_drawingGroupData) {
708 $escherWorkbook =
$reader->load($this->_drawingGroupData);
716 foreach ($this->_sheets as $sheet) {
718 if ($sheet[
'sheetType'] != 0x00) {
724 if (isset($this->_loadSheetsOnly) && !in_array($sheet[
'name'], $this->_loadSheetsOnly)) {
729 $this->_phpSheet = $this->_phpExcel->createSheet();
730 $this->_phpSheet->setTitle($sheet[
'name']);
731 $this->_phpSheet->setSheetState($sheet[
'sheetState']);
733 $this->_pos = $sheet[
'offset'];
736 $this->_isFitToPages =
false;
739 $this->_drawingData =
'';
742 $this->_objs = array();
745 $this->_sharedFormulaParts = array();
748 $this->_sharedFormulas = array();
751 $this->_textObjects = array();
754 $this->_cellNotes = array();
755 $this->textObjRef = -1;
757 while ($this->_pos <= $this->_dataSize - 4) {
761 case self::XLS_Type_BOF: $this->
_readBof();
break;
764 case self::XLS_Type_SHEETPR: $this->
_readSheetPr();
break;
767 case self::XLS_Type_HEADER: $this->
_readHeader();
break;
768 case self::XLS_Type_FOOTER: $this->
_readFooter();
break;
769 case self::XLS_Type_HCENTER: $this->
_readHcenter();
break;
770 case self::XLS_Type_VCENTER: $this->
_readVcenter();
break;
776 case self::XLS_Type_PROTECT: $this->
_readProtect();
break;
781 case self::XLS_Type_COLINFO: $this->
_readColInfo();
break;
782 case self::XLS_Type_DIMENSION: $this->
_readDefault();
break;
783 case self::XLS_Type_ROW: $this->
_readRow();
break;
784 case self::XLS_Type_DBCELL: $this->
_readDefault();
break;
785 case self::XLS_Type_RK: $this->
_readRk();
break;
787 case self::XLS_Type_MULRK: $this->
_readMulRk();
break;
788 case self::XLS_Type_NUMBER: $this->
_readNumber();
break;
789 case self::XLS_Type_FORMULA: $this->
_readFormula();
break;
791 case self::XLS_Type_BOOLERR: $this->
_readBoolErr();
break;
793 case self::XLS_Type_LABEL: $this->
_readLabel();
break;
794 case self::XLS_Type_BLANK: $this->
_readBlank();
break;
796 case self::XLS_Type_OBJ: $this->
_readObj();
break;
797 case self::XLS_Type_WINDOW2: $this->
_readWindow2();
break;
798 case self::XLS_Type_SCL: $this->
_readScl();
break;
799 case self::XLS_Type_PANE: $this->
_readPane();
break;
808 case self::XLS_Type_NOTE: $this->
_readNote();
break;
812 case self::XLS_Type_EOF: $this->
_readDefault();
break 2;
819 if (!$this->_readDataOnly && $this->_drawingData) {
822 $escherWorksheet =
$reader->load($this->_drawingData);
829 $allSpContainers = $escherWorksheet->getDgContainer()->getSpgrContainer()->getAllSpContainers();
833 foreach ($this->_objs as $n => $obj) {
839 $spContainer = $allSpContainers[$n + 1];
842 if ($spContainer->getNestingLevel() > 1) {
850 $startOffsetX = $spContainer->getStartOffsetX();
851 $startOffsetY = $spContainer->getStartOffsetY();
852 $endOffsetX = $spContainer->getEndOffsetX();
853 $endOffsetY = $spContainer->getEndOffsetY();
862 switch ($obj[
'otObjType']) {
869 if (isset($this->_cellNotes[$obj[
'idObjID']])) {
870 $cellNote = $this->_cellNotes[$obj[
'idObjID']];
876 if (isset($this->_textObjects[$obj[
'idObjID']])) {
877 $textObject = $this->_textObjects[$obj[
'idObjID']];
882 $this->_cellNotes[$obj[
'idObjID']][
'objTextData'] = $textObject;
883 $text = $textObject[
'text'];
894 $BSEindex = $spContainer->getOPT(0x0104);
895 $BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();
896 $BSE = $BSECollection[$BSEindex - 1];
897 $blipType = $BSE->getBlipType();
900 if ($blip = $BSE->getBlip()) {
901 $ih = imagecreatefromstring($blip->getData());
903 $drawing->setImageResource($ih);
906 $drawing->setResizeProportional(
false);
907 $drawing->setWidth($width);
908 $drawing->setHeight($height);
909 $drawing->setOffsetX($offsetX);
910 $drawing->setOffsetY($offsetY);
924 $drawing->setWorksheet($this->_phpSheet);
925 $drawing->setCoordinates($spContainer->getStartCoordinates());
938 if ($this->_version == self::XLS_BIFF8) {
939 foreach ($this->_sharedFormulaParts as $cell => $baseCell) {
948 if (count($this->_cellNotes) > 0) {
949 foreach($this->_cellNotes as $note => $noteDetails) {
953 $cellAddress = str_replace(
'$',
'',$noteDetails[
'cellRef']);
954 $this->_phpSheet->getComment( $cellAddress )
955 ->setAuthor( $noteDetails[
'author'] )
956 ->setText($this->
_parseRichText($noteDetails[
'objTextData'][
'text']) );
962 foreach ($this->_definedname as $definedName) {
963 if ($definedName[
'isBuiltInName']) {
964 switch ($definedName[
'name']) {
966 case pack(
'C', 0x06):
970 $ranges = explode(
',', $definedName[
'formula']);
972 $extractedRanges = array();
973 foreach ($ranges as $range) {
978 $explodes = explode(
'!', $range);
979 $sheetName = $explodes[0];
981 if (count($explodes) == 2) {
982 $extractedRanges[] = str_replace(
'$',
'', $explodes[1]);
985 if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) {
986 $docSheet->getPageSetup()->setPrintArea(implode(
',', $extractedRanges));
990 case pack(
'C', 0x07):
1002 $ranges = explode(
',', $definedName[
'formula']);
1004 foreach ($ranges as $range) {
1009 $explodes = explode(
'!', $range);
1011 if (count($explodes) == 2) {
1012 if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
1014 $extractedRange = $explodes[1];
1015 $extractedRange = str_replace(
'$',
'', $extractedRange);
1017 $coordinateStrings = explode(
':', $extractedRange);
1018 if (count($coordinateStrings) == 2) {
1022 if ($firstColumn ==
'A' and $lastColumn ==
'IV') {
1024 $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow));
1025 } elseif ($firstRow == 1 and $lastRow == 65536) {
1027 $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn));
1038 $explodes = explode(
'!', $definedName[
'formula']);
1040 if (count($explodes) == 2) {
1041 if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
1042 $extractedRange = $explodes[1];
1043 $extractedRange = str_replace(
'$',
'', $extractedRange);
1045 $localOnly = ($definedName[
'scope'] == 0) ?
false :
true;
1046 $scope = ($definedName[
'scope'] == 0) ?
1047 null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName[
'scope'] - 1][
'name']);
1049 $this->_phpExcel->addNamedRange(
new PHPExcel_NamedRange((
string)$definedName[
'name'], $docSheet, $extractedRange, $localOnly, $scope) );
1069 $res = $ole->read($pFilename);
1071 $this->_data = $ole->getStream($ole->wrkbook);
1074 $this->_summaryInformation = $ole->getStream($ole->summaryInformation);
1077 $this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation);
1088 if (!isset($this->_summaryInformation)) {
1109 $countProperties =
self::_GetInt4d($this->_summaryInformation, $secOffset+4);
1112 $codePage =
'CP1252';
1116 for ($i = 0; $i < $countProperties; ++$i) {
1119 $id =
self::_GetInt4d($this->_summaryInformation, ($secOffset+8) + (8 * $i));
1123 $offset =
self::_GetInt4d($this->_summaryInformation, ($secOffset+12) + (8 * $i));
1133 $value =
self::_GetInt2d($this->_summaryInformation, $secOffset + 4 + $offset);
1137 $value =
self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset);
1145 $byteLength =
self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset);
1146 $value = substr($this->_summaryInformation, $secOffset + 8 + $offset, $byteLength);
1148 $value = rtrim($value);
1167 $this->_phpExcel->getProperties()->setTitle($value);
1171 $this->_phpExcel->getProperties()->setSubject($value);
1175 $this->_phpExcel->getProperties()->setCreator($value);
1179 $this->_phpExcel->getProperties()->setKeywords($value);
1183 $this->_phpExcel->getProperties()->setDescription($value);
1191 $this->_phpExcel->getProperties()->setLastModifiedBy($value);
1207 $this->_phpExcel->getProperties()->setCreated($value);
1211 $this->_phpExcel->getProperties()->setModified($value);
1247 if (!isset($this->_documentSummaryInformation)) {
1267 $secLength =
self::_GetInt4d($this->_documentSummaryInformation, $secOffset);
1271 $countProperties =
self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4);
1275 $codePage =
'CP1252';
1279 for ($i = 0; $i < $countProperties; ++$i) {
1282 $id =
self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i));
1287 $offset =
self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i));
1298 $value =
self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
1302 $value =
self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
1310 $byteLength =
self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
1311 $value = substr($this->_documentSummaryInformation, $secOffset + 8 + $offset, $byteLength);
1313 $value = rtrim($value);
1332 $this->_phpExcel->getProperties()->setCategory($value);
1380 $this->_phpExcel->getProperties()->setManager($value);
1384 $this->_phpExcel->getProperties()->setCompany($value);
1404 $this->_pos += 4 + $length;
1416 $recordData = substr($this->_data, $this->_pos + 4, $length);
1419 $this->_pos += 4 + $length;
1421 if ($this->_readDataOnly) {
1426 if ($this->_version == self::XLS_BIFF8) {
1429 $noteAuthor = $noteAuthor[
'value'];
1434 $this->_cellNotes[$noteObjID] = array(
'cellRef' => $cellAddress,
1435 'objectID' => $noteObjID,
1436 'author' => $noteAuthor
1440 if ($cellAddress ==
'$B$65536') {
1446 $cellAddress = array_pop(array_keys($this->_phpSheet->getComments()));
1450 $cellAddress = str_replace(
'$',
'',$cellAddress);
1452 $noteText = trim(substr($recordData, 6));
1458 $comment = $this->_phpSheet->getComment( $cellAddress );
1459 $commentText =
$comment->getText()->getPlainText();
1463 $this->_phpSheet->getComment( $cellAddress )
1477 $recordData = substr($this->_data, $this->_pos + 4, $length);
1480 $this->_pos += 4 + $length;
1482 if ($this->_readDataOnly) {
1498 $this->_textObjects[$this->textObjRef] = array(
1499 'text' => substr($text[
"recordData"],$text[
"spliceOffsets"][0]+1,$cchText),
1500 'format' => substr($text[
"recordData"],$text[
"spliceOffsets"][1],$cbRuns),
1501 'alignment' => $grbitOpts,
1516 $recordData = substr($this->_data, $this->_pos + 4, $length);
1519 $this->_pos += 4 + $length;
1524 switch ($substreamType) {
1525 case self::XLS_WorkbookGlobals:
1527 if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) {
1528 throw new Exception(
'Cannot read this Excel file. Version is too old.');
1530 $this->_version = $version;
1533 case self::XLS_Worksheet:
1544 }
while ($code != self::XLS_Type_EOF && $this->_pos < $this->_dataSize);
1566 $this->_pos += 4 + $length;
1568 throw new Exception(
'Cannot read encrypted file');
1583 $recordData = substr($this->_data, $this->_pos + 4, $length);
1586 $this->_pos += 4 + $length;
1609 $recordData = substr($this->_data, $this->_pos + 4, $length);
1612 $this->_pos += 4 + $length;
1616 if (ord($recordData{0}) == 1) {
1627 $recordData = substr($this->_data, $this->_pos + 4, $length);
1630 $this->_pos += 4 + $length;
1632 if (!$this->_readDataOnly) {
1637 $objFont->setSize($size / 20);
1643 if ($isItalic) $objFont->setItalic(
true);
1648 if ($isStrike) $objFont->setStrikethrough(
true);
1652 $objFont->colorIndex = $colorIndex;
1658 $objFont->setBold(
true);
1664 switch ($escapement) {
1666 $objFont->setSuperScript(
true);
1669 $objFont->setSubScript(
true);
1674 $underlineType = ord($recordData{10});
1675 switch ($underlineType) {
1696 if ($this->_version == self::XLS_BIFF8) {
1701 $objFont->setName($string[
'value']);
1703 $this->_objFonts[] = $objFont;
1724 $recordData = substr($this->_data, $this->_pos + 4, $length);
1727 $this->_pos += 4 + $length;
1729 if (!$this->_readDataOnly) {
1732 if ($this->_version == self::XLS_BIFF8) {
1739 $formatString = $string[
'value'];
1740 $this->_formats[$indexCode] = $formatString;
1761 $recordData = substr($this->_data, $this->_pos + 4, $length);
1764 $this->_pos += 4 + $length;
1768 if (!$this->_readDataOnly) {
1770 if (self::_GetInt2d($recordData, 0) < 4) {
1777 $objStyle->setFont($this->_objFonts[$fontIndex]);
1781 if (isset($this->_formats[$numberFormatIndex])) {
1783 $numberformat = array(
'code' => $this->_formats[$numberFormatIndex]);
1786 $numberformat = array(
'code' => $code);
1789 $numberformat = array(
'code' =>
'General');
1791 $objStyle->getNumberFormat()->setFormatCode($numberformat[
'code']);
1797 $isLocked = (0x01 & $xfTypeProt) >> 0;
1798 $objStyle->getProtection()->setLocked($isLocked ?
1802 $isHidden = (0x02 & $xfTypeProt) >> 1;
1803 $objStyle->getProtection()->setHidden($isHidden ?
1807 $isCellStyleXf = (0x04 & $xfTypeProt) >> 2;
1811 $horAlign = (0x07 & ord($recordData{6})) >> 0;
1812 switch ($horAlign) {
1833 $wrapText = (0x08 & ord($recordData{6})) >> 3;
1834 switch ($wrapText) {
1836 $objStyle->getAlignment()->setWrapText(
false);
1839 $objStyle->getAlignment()->setWrapText(
true);
1843 $vertAlign = (0x70 & ord($recordData{6})) >> 4;
1844 switch ($vertAlign) {
1859 if ($this->_version == self::XLS_BIFF8) {
1861 $angle = ord($recordData{7});
1865 }
else if ($angle <= 180) {
1866 $rotation = 90 - $angle;
1867 }
else if ($angle == 255) {
1870 $objStyle->getAlignment()->setTextRotation($rotation);
1874 $indent = (0x0F & ord($recordData{8})) >> 0;
1875 $objStyle->getAlignment()->setIndent($indent);
1878 $shrinkToFit = (0x10 & ord($recordData{8})) >> 4;
1879 switch ($shrinkToFit) {
1881 $objStyle->getAlignment()->setShrinkToFit(
false);
1884 $objStyle->getAlignment()->setShrinkToFit(
true);
1892 if ($bordersLeftStyle = self::_mapBorderStyle((0x0000000F & self::_GetInt4d($recordData, 10)) >> 0)) {
1893 $objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle);
1896 if ($bordersRightStyle = self::_mapBorderStyle((0x000000F0 & self::_GetInt4d($recordData, 10)) >> 4)) {
1897 $objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle);
1900 if ($bordersTopStyle = self::_mapBorderStyle((0x00000F00 & self::_GetInt4d($recordData, 10)) >> 8)) {
1901 $objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle);
1904 if ($bordersBottomStyle = self::_mapBorderStyle((0x0000F000 & self::_GetInt4d($recordData, 10)) >> 12)) {
1905 $objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle);
1908 $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 &
self::_GetInt4d($recordData, 10)) >> 16;
1911 $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 &
self::_GetInt4d($recordData, 10)) >> 23;
1914 $diagonalDown = (0x40000000 &
self::_GetInt4d($recordData, 10)) >> 30 ?
1921 if ($diagonalUp ==
false && $diagonalDown ==
false) {
1923 } elseif ($diagonalUp ==
true && $diagonalDown ==
false) {
1925 } elseif ($diagonalUp ==
false && $diagonalDown ==
true) {
1927 } elseif ($diagonalUp ==
true && $diagonalDown ==
true) {
1933 $objStyle->getBorders()->getTop()->colorIndex = (0x0000007F &
self::_GetInt4d($recordData, 14)) >> 0;
1936 $objStyle->getBorders()->getBottom()->colorIndex = (0x00003F80 &
self::_GetInt4d($recordData, 14)) >> 7;
1939 $objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 &
self::_GetInt4d($recordData, 14)) >> 14;
1942 if ($bordersDiagonalStyle = self::_mapBorderStyle((0x01E00000 & self::_GetInt4d($recordData, 14)) >> 21)) {
1943 $objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle);
1947 if ($fillType = self::_mapFillPattern((0xFC000000 & self::_GetInt4d($recordData, 14)) >> 26)) {
1948 $objStyle->getFill()->setFillType($fillType);
1952 $objStyle->getFill()->startcolorIndex = (0x007F &
self::_GetInt2d($recordData, 18)) >> 0;
1955 $objStyle->getFill()->endcolorIndex = (0x3F80 &
self::_GetInt2d($recordData, 18)) >> 7;
1960 $orientationAndFlags = ord($recordData{7});
1963 $xfOrientation = (0x03 & $orientationAndFlags) >> 0;
1964 switch ($xfOrientation) {
1966 $objStyle->getAlignment()->setTextRotation(0);
1969 $objStyle->getAlignment()->setTextRotation(-165);
1972 $objStyle->getAlignment()->setTextRotation(90);
1975 $objStyle->getAlignment()->setTextRotation(-90);
1983 $objStyle->getFill()->startcolorIndex = (0x0000007F & $borderAndBackground) >> 0;
1986 $objStyle->getFill()->endcolorIndex = (0x00003F80 & $borderAndBackground) >> 7;
1989 $objStyle->getFill()->setFillType(self::_mapFillPattern((0x003F0000 & $borderAndBackground) >> 16));
1992 $objStyle->getBorders()->getBottom()->setBorderStyle(self::_mapBorderStyle((0x01C00000 & $borderAndBackground) >> 22));
1995 $objStyle->getBorders()->getBottom()->colorIndex = (0xFE000000 & $borderAndBackground) >> 25;
2001 $objStyle->getBorders()->getTop()->setBorderStyle(self::_mapBorderStyle((0x00000007 & $borderLines) >> 0));
2004 $objStyle->getBorders()->getLeft()->setBorderStyle(self::_mapBorderStyle((0x00000038 & $borderLines) >> 3));
2007 $objStyle->getBorders()->getRight()->setBorderStyle(self::_mapBorderStyle((0x000001C0 & $borderLines) >> 6));
2010 $objStyle->getBorders()->getTop()->colorIndex = (0x0000FE00 & $borderLines) >> 9;
2013 $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & $borderLines) >> 16;
2016 $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & $borderLines) >> 23;
2020 if ($isCellStyleXf) {
2022 if ($this->_xfIndex == 0) {
2023 $this->_phpExcel->addCellStyleXf($objStyle);
2028 $this->_phpExcel->addCellXf($objStyle);
2029 $this->_mapCellXfIndex[
$this->_xfIndex] = count($this->_phpExcel->getCellXfCollection()) - 1;
2043 $recordData = substr($this->_data, $this->_pos + 4, $length);
2046 $this->_pos += 4 + $length;
2048 if (!$this->_readDataOnly) {
2067 while ($offset < $length) {
2075 $extData = substr($recordData, $offset + 4, $cb);
2080 $xclrValue = substr($extData, 4, 4);
2082 if ($xclfType == 2) {
2083 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2086 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2087 $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
2088 $fill->getStartColor()->setRGB($rgb);
2089 unset($fill->startcolorIndex);
2096 $xclrValue = substr($extData, 4, 4);
2098 if ($xclfType == 2) {
2099 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2102 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2103 $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
2104 $fill->getEndColor()->setRGB($rgb);
2105 unset($fill->endcolorIndex);
2112 $xclrValue = substr($extData, 4, 4);
2114 if ($xclfType == 2) {
2115 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2118 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2119 $top = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getTop();
2120 $top->getColor()->setRGB($rgb);
2121 unset($top->colorIndex);
2128 $xclrValue = substr($extData, 4, 4);
2130 if ($xclfType == 2) {
2131 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2134 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2135 $bottom = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getBottom();
2136 $bottom->getColor()->setRGB($rgb);
2137 unset($bottom->colorIndex);
2144 $xclrValue = substr($extData, 4, 4);
2146 if ($xclfType == 2) {
2147 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2150 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2151 $left = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getLeft();
2152 $left->getColor()->setRGB($rgb);
2153 unset($left->colorIndex);
2160 $xclrValue = substr($extData, 4, 4);
2162 if ($xclfType == 2) {
2163 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2166 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2167 $right = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getRight();
2168 $right->getColor()->setRGB($rgb);
2169 unset($right->colorIndex);
2176 $xclrValue = substr($extData, 4, 4);
2178 if ($xclfType == 2) {
2179 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2182 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2183 $diagonal = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
2184 $diagonal->getColor()->setRGB($rgb);
2185 unset($diagonal->colorIndex);
2192 $xclrValue = substr($extData, 4, 4);
2194 if ($xclfType == 2) {
2195 $rgb = sprintf(
'%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2198 if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
2199 $font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont();
2200 $font->getColor()->setRGB($rgb);
2201 unset($font->colorIndex);
2219 $recordData = substr($this->_data, $this->_pos + 4, $length);
2222 $this->_pos += 4 + $length;
2224 if (!$this->_readDataOnly) {
2229 $xfIndex = (0x0FFF & $ixfe) >> 0;
2232 $isBuiltIn = (bool) ((0x8000 & $ixfe) >> 15);
2236 $builtInId = ord($recordData{2});
2238 switch ($builtInId) {
2259 $recordData = substr($this->_data, $this->_pos + 4, $length);
2262 $this->_pos += 4 + $length;
2264 if (!$this->_readDataOnly) {
2269 for ($i = 0; $i < $nm; ++$i) {
2270 $rgb = substr($recordData, 2 + 4 * $i, 4);
2291 $recordData = substr($this->_data, $this->_pos + 4, $length);
2294 $this->_pos += 4 + $length;
2300 switch (ord($recordData{4})) {
2308 $sheetType = ord($recordData{5});
2311 if ($this->_version == self::XLS_BIFF8) {
2313 $rec_name = $string[
'value'];
2314 } elseif ($this->_version == self::XLS_BIFF7) {
2316 $rec_name = $string[
'value'];
2319 $this->_sheets[] = array(
2320 'name' => $rec_name,
2321 'offset' => $rec_offset,
2322 'sheetState' => $sheetState,
2323 'sheetType' => $sheetType,
2333 $recordData = substr($this->_data, $this->_pos + 4, $length);
2336 $this->_pos += 4 + $length;
2342 if (strlen($recordData) > 4) {
2350 $offset += $encodedUrlString[
'size'];
2353 $externalSheetNames = array();
2354 for ($i = 0; $i < $nm; ++$i) {
2356 $externalSheetNames[] = $externalSheetNameString[
'value'];
2357 $offset += $externalSheetNameString[
'size'];
2361 $this->_externalBooks[] = array(
2362 'type' =>
'external',
2363 'encodedUrl' => $encodedUrlString[
'value'],
2364 'externalSheetNames' => $externalSheetNames,
2367 } elseif (substr($recordData, 2, 2) == pack(
'CC', 0x01, 0x04)) {
2371 $this->_externalBooks[] = array(
2372 'type' =>
'internal',
2374 } elseif (substr($recordData, 0, 4) == pack(
'vCC', 0x0001, 0x01, 0x3A)) {
2377 $this->_externalBooks[] = array(
2378 'type' =>
'addInFunction',
2380 } elseif (substr($recordData, 0, 2) == pack(
'v', 0x0000)) {
2384 $this->_externalBooks[] = array(
2385 'type' =>
'DDEorOLE',
2396 $recordData = substr($this->_data, $this->_pos + 4, $length);
2399 $this->_pos += 4 + $length;
2402 if ($this->_version == self::XLS_BIFF8) {
2414 $offset = 6 + $nameString[
'size'];
2417 $this->_externalNames[] = array(
2418 'name' => $nameString[
'value'],
2419 'formula' => $formula,
2430 $recordData = substr($this->_data, $this->_pos + 4, $length);
2433 $this->_pos += 4 + $length;
2436 if ($this->_version == self::XLS_BIFF8) {
2439 for ($i = 0; $i < $nm; ++$i) {
2440 $this->_ref[] = array(
2442 'externalBookIndex' => self::_GetInt2d($recordData, 2 + 6 * $i),
2444 'firstSheetIndex' => self::_GetInt2d($recordData, 4 + 6 * $i),
2446 'lastSheetIndex' => self::_GetInt2d($recordData, 6 + 6 * $i),
2466 $recordData = substr($this->_data, $this->_pos + 4, $length);
2469 $this->_pos += 4 + $length;
2471 if ($this->_version == self::XLS_BIFF8) {
2478 $isBuiltInName = (0x0020 & $opts) >> 5;
2483 $nlen = ord($recordData{3});
2496 $offset = 14 + $string[
'size'];
2497 $formulaStructure = pack(
'v', $flen) . substr($recordData, $offset);
2505 $this->_definedname[] = array(
2506 'isBuiltInName' => $isBuiltInName,
2507 'name' => $string[
'value'],
2508 'formula' => $formula,
2523 $recordData = $splicedRecordData[
'recordData'];
2525 $this->_drawingGroupData .= $recordData;
2547 $recordData = $splicedRecordData[
'recordData'];
2548 $spliceOffsets = $splicedRecordData[
'spliceOffsets'];
2558 for ($i = 0; $i < $nm; ++$i) {
2565 $optionFlags = ord($recordData{
$pos});
2569 $isCompressed = (($optionFlags & 0x01) == 0) ;
2572 $hasAsian = (($optionFlags & 0x04) != 0);
2575 $hasRichText = (($optionFlags & 0x08) != 0);
2590 $len = ($isCompressed) ? $numChars : $numChars * 2;
2593 foreach ($spliceOffsets as $spliceOffset) {
2596 if ($pos <= $spliceOffset) {
2597 $limitpos = $spliceOffset;
2602 if ($pos + $len <= $limitpos) {
2605 $retstr = substr($recordData, $pos, $len);
2612 $retstr = substr($recordData, $pos, $limitpos - $pos);
2614 $bytesRead = $limitpos -
$pos;
2617 $charsLeft = $numChars - (($isCompressed) ? $bytesRead : ($bytesRead / 2));
2622 while ($charsLeft > 0) {
2625 foreach ($spliceOffsets as $spliceOffset) {
2626 if ($pos < $spliceOffset) {
2627 $limitpos = $spliceOffset;
2634 $option = ord($recordData{$pos});
2637 if ($isCompressed && ($option == 0)) {
2640 $len = min($charsLeft, $limitpos - $pos);
2641 $retstr .= substr($recordData, $pos, $len);
2643 $isCompressed =
true;
2645 } elseif (!$isCompressed && ($option != 0)) {
2648 $len = min($charsLeft * 2, $limitpos - $pos);
2649 $retstr .= substr($recordData, $pos, $len);
2650 $charsLeft -= $len / 2;
2651 $isCompressed =
false;
2653 } elseif (!$isCompressed && ($option == 0)) {
2656 $len = min($charsLeft, $limitpos - $pos);
2657 for ($j = 0; $j < $len; ++$j) {
2658 $retstr .= $recordData{$pos + $j} . chr(0);
2661 $isCompressed =
false;
2667 for ($j = 0; $j < strlen($retstr); ++$j) {
2668 $newstr .= $retstr[$j] . chr(0);
2671 $len = min($charsLeft * 2, $limitpos - $pos);
2672 $retstr .= substr($recordData, $pos, $len);
2673 $charsLeft -= $len / 2;
2674 $isCompressed =
false;
2688 for ($j = 0; $j < $formattingRuns; ++$j) {
2696 'charPos' => $charPos,
2697 'fontIndex' => $fontIndex,
2700 $pos += 4 * $formattingRuns;
2706 $pos += $extendedRunLength;
2710 $this->_sst[] = array(
2712 'fmtRuns' => $fmtRuns,
2725 $recordData = substr($this->_data, $this->_pos + 4, $length);
2728 $this->_pos += 4 + $length;
2730 if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
2732 $printGridlines = (bool) self::_GetInt2d($recordData, 0);
2733 $this->_phpSheet->setPrintGridlines($printGridlines);
2743 $recordData = substr($this->_data, $this->_pos + 4, $length);
2746 $this->_pos += 4 + $length;
2751 $this->_phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
2760 $recordData = substr($this->_data, $this->_pos + 4, $length);
2763 $this->_pos += 4 + $length;
2769 $this->_phpSheet->setShowSummaryBelow($isSummaryBelow);
2773 $this->_phpSheet->setShowSummaryRight($isSummaryRight);
2777 $this->_isFitToPages = (bool) ((0x0100 & self::_GetInt2d($recordData, 0)) >> 8);
2786 $recordData = substr($this->_data, $this->_pos + 4, $length);
2789 $this->_pos += 4 + $length;
2791 if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
2797 for ($i = 0; $i < $nm; ++$i) {
2814 $recordData = substr($this->_data, $this->_pos + 4, $length);
2817 $this->_pos += 4 + $length;
2819 if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
2824 for ($i = 0; $i < $nm; ++$i) {
2841 $recordData = substr($this->_data, $this->_pos + 4, $length);
2844 $this->_pos += 4 + $length;
2846 if (!$this->_readDataOnly) {
2850 if ($this->_version == self::XLS_BIFF8) {
2856 $this->_phpSheet->getHeaderFooter()->setOddHeader($string[
'value']);
2857 $this->_phpSheet->getHeaderFooter()->setEvenHeader($string[
'value']);
2868 $recordData = substr($this->_data, $this->_pos + 4, $length);
2871 $this->_pos += 4 + $length;
2873 if (!$this->_readDataOnly) {
2877 if ($this->_version == self::XLS_BIFF8) {
2882 $this->_phpSheet->getHeaderFooter()->setOddFooter($string[
'value']);
2883 $this->_phpSheet->getHeaderFooter()->setEvenFooter($string[
'value']);
2894 $recordData = substr($this->_data, $this->_pos + 4, $length);
2897 $this->_pos += 4 + $length;
2899 if (!$this->_readDataOnly) {
2901 $isHorizontalCentered = (bool) self::_GetInt2d($recordData, 0);
2903 $this->_phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
2913 $recordData = substr($this->_data, $this->_pos + 4, $length);
2916 $this->_pos += 4 + $length;
2918 if (!$this->_readDataOnly) {
2920 $isVerticalCentered = (bool) self::_GetInt2d($recordData, 0);
2922 $this->_phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
2932 $recordData = substr($this->_data, $this->_pos + 4, $length);
2935 $this->_pos += 4 + $length;
2937 if (!$this->_readDataOnly) {
2939 $this->_phpSheet->getPageMargins()->setLeft(self::_extractNumber($recordData));
2949 $recordData = substr($this->_data, $this->_pos + 4, $length);
2952 $this->_pos += 4 + $length;
2954 if (!$this->_readDataOnly) {
2956 $this->_phpSheet->getPageMargins()->setRight(self::_extractNumber($recordData));
2966 $recordData = substr($this->_data, $this->_pos + 4, $length);
2969 $this->_pos += 4 + $length;
2971 if (!$this->_readDataOnly) {
2973 $this->_phpSheet->getPageMargins()->setTop(self::_extractNumber($recordData));
2983 $recordData = substr($this->_data, $this->_pos + 4, $length);
2986 $this->_pos += 4 + $length;
2988 if (!$this->_readDataOnly) {
2990 $this->_phpSheet->getPageMargins()->setBottom(self::_extractNumber($recordData));
3000 $recordData = substr($this->_data, $this->_pos + 4, $length);
3003 $this->_pos += 4 + $length;
3005 if (!$this->_readDataOnly) {
3028 $this->_phpSheet->getPageSetup()->setPaperSize($paperSize);
3029 switch ($isPortrait) {
3034 $this->_phpSheet->getPageSetup()->setScale($scale,
false);
3035 $this->_phpSheet->getPageSetup()->setFitToPage((
bool) $this->_isFitToPages);
3036 $this->_phpSheet->getPageSetup()->setFitToWidth($fitToWidth,
false);
3037 $this->_phpSheet->getPageSetup()->setFitToHeight($fitToHeight,
false);
3042 $this->_phpSheet->getPageMargins()->setHeader($marginHeader);
3046 $this->_phpSheet->getPageMargins()->setFooter($marginFooter);
3057 $recordData = substr($this->_data, $this->_pos + 4, $length);
3060 $this->_pos += 4 + $length;
3062 if ($this->_readDataOnly) {
3070 $this->_phpSheet->getProtection()->setSheet((
bool)$bool);
3079 $recordData = substr($this->_data, $this->_pos + 4, $length);
3082 $this->_pos += 4 + $length;
3084 if ($this->_readDataOnly) {
3093 $this->_phpSheet->getProtection()->setScenarios((
bool)$bool);
3102 $recordData = substr($this->_data, $this->_pos + 4, $length);
3105 $this->_pos += 4 + $length;
3107 if ($this->_readDataOnly) {
3116 $this->_phpSheet->getProtection()->setObjects((
bool)$bool);
3125 $recordData = substr($this->_data, $this->_pos + 4, $length);
3128 $this->_pos += 4 + $length;
3130 if (!$this->_readDataOnly) {
3132 $password = strtoupper(dechex(self::_GetInt2d($recordData, 0)));
3133 $this->_phpSheet->getProtection()->setPassword($password,
true);
3143 $recordData = substr($this->_data, $this->_pos + 4, $length);
3146 $this->_pos += 4 + $length;
3151 $this->_phpSheet->getDefaultColumnDimension()->setWidth($width);
3161 $recordData = substr($this->_data, $this->_pos + 4, $length);
3164 $this->_pos += 4 + $length;
3166 if (!$this->_readDataOnly) {
3192 for ($i = $fc; $i <= $lc; ++$i) {
3193 if ($lc == 255 || $lc == 256) {
3194 $this->_phpSheet->getDefaultColumnDimension()->setWidth($width / 256);
3197 $this->_phpSheet->getColumnDimensionByColumn($i)->setWidth($width / 256);
3198 $this->_phpSheet->getColumnDimensionByColumn($i)->setVisible(!$isHidden);
3199 $this->_phpSheet->getColumnDimensionByColumn($i)->setOutlineLevel($level);
3200 $this->_phpSheet->getColumnDimensionByColumn($i)->setCollapsed($isCollapsed);
3201 $this->_phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3219 $recordData = substr($this->_data, $this->_pos + 4, $length);
3222 $this->_pos += 4 + $length;
3224 if (!$this->_readDataOnly) {
3240 if (!$useDefaultHeight) {
3241 $this->_phpSheet->getRowDimension($r + 1)->setRowHeight($height / 20);
3252 $this->_phpSheet->getRowDimension($r + 1)->setOutlineLevel($level);
3256 $this->_phpSheet->getRowDimension($r + 1)->setCollapsed($isCollapsed);
3260 $this->_phpSheet->getRowDimension($r + 1)->setVisible(!$isHidden);
3263 $hasExplicitFormat = (0x00000080 &
self::_GetInt4d($recordData, 12)) >> 7;
3268 if ($hasExplicitFormat) {
3269 $this->_phpSheet->getRowDimension($r + 1)->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3288 $recordData = substr($this->_data, $this->_pos + 4, $length);
3291 $this->_pos += 4 + $length;
3309 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3310 if (!$this->_readDataOnly) {
3312 $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3332 $recordData = substr($this->_data, $this->_pos + 4, $length);
3335 $this->_pos += 4 + $length;
3353 if (($fmtRuns = $this->_sst[$index][
'fmtRuns']) && !$this->_readDataOnly) {
3357 $sstCount = count($this->_sst[$index][
'fmtRuns']);
3358 for ($i = 0; $i <= $sstCount; ++$i) {
3359 if (isset($fmtRuns[$i])) {
3361 $charPos = $fmtRuns[$i][
'charPos'];
3368 $richText->createText($text);
3370 $textRun = $richText->createTextRun($text);
3371 if (isset($fmtRuns[$i - 1])) {
3372 if ($fmtRuns[$i - 1][
'fontIndex'] < 4) {
3373 $fontIndex = $fmtRuns[$i - 1][
'fontIndex'];
3377 $fontIndex = $fmtRuns[$i - 1][
'fontIndex'] - 1;
3379 $textRun->setFont(clone $this->_objFonts[$fontIndex]);
3384 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3387 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3391 if (!$this->_readDataOnly) {
3393 $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3409 $recordData = substr($this->_data, $this->_pos + 4, $length);
3412 $this->_pos += 4 + $length;
3422 $columns = $colLast - $colFirst + 1;
3427 for ($i = 0; $i < $columns; ++$i) {
3438 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3439 if (!$this->_readDataOnly) {
3441 $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3463 $recordData = substr($this->_data, $this->_pos + 4, $length);
3466 $this->_pos += 4 + $length;
3482 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3483 if (!$this->_readDataOnly) {
3485 $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3504 $recordData = substr($this->_data, $this->_pos + 4, $length);
3507 $this->_pos += 4 + $length;
3517 $formulaStructure = substr($recordData, 20);
3525 $isPartOfSharedFormula = (bool) (0x0008 & $options);
3531 $isPartOfSharedFormula = $isPartOfSharedFormula && ord($formulaStructure{2}) == 0x01;
3533 if ($isPartOfSharedFormula) {
3544 if ($isPartOfSharedFormula) {
3546 $this->_sharedFormulaParts[$columnString . (
$row + 1)] = $this->_baseCell;
3555 if ( (ord($recordData{6}) == 0)
3556 && (ord($recordData{12}) == 255)
3557 && (ord($recordData{13}) == 255) ) {
3564 if ($code == self::XLS_Type_SHAREDFMLA) {
3571 } elseif ((ord($recordData{6}) == 1)
3572 && (ord($recordData{12}) == 255)
3573 && (ord($recordData{13}) == 255)) {
3577 $value = (bool) ord($recordData{8});
3579 } elseif ((ord($recordData{6}) == 2)
3580 && (ord($recordData{12}) == 255)
3581 && (ord($recordData{13}) == 255)) {
3587 } elseif ((ord($recordData{6}) == 3)
3588 && (ord($recordData{12}) == 255)
3589 && (ord($recordData{13}) == 255)) {
3603 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3604 if (!$this->_readDataOnly) {
3606 $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3610 if (!$isPartOfSharedFormula) {
3614 if ($this->_version != self::XLS_BIFF8) {
3615 throw new Exception(
'Not BIFF8. Can only read BIFF8 formulas');
3621 $cell->setValueExplicit($value, $dataType);
3624 if ($this->_version == self::XLS_BIFF8) {
3627 $cell->setValueExplicit($value, $dataType);
3632 $cell->setCalculatedValue($value);
3644 $recordData = substr($this->_data, $this->_pos + 4, $length);
3647 $this->_pos += 4 + $length;
3650 $cellRange = substr($recordData, 0, 6);
3656 $no = ord($recordData{7});
3659 $formula = substr($recordData, 8);
3662 $this->_sharedFormulas[$this->_baseCell] = $formula;
3676 $recordData = substr($this->_data, $this->_pos + 4, $length);
3679 $this->_pos += 4 + $length;
3681 if ($this->_version == self::XLS_BIFF8) {
3683 $value = $string[
'value'];
3686 $value = $string[
'value'];
3703 $recordData = substr($this->_data, $this->_pos + 4, $length);
3706 $this->_pos += 4 + $length;
3721 $boolErr = ord($recordData{6});
3724 $isError = ord($recordData{7});
3726 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3729 $value = (bool) $boolErr;
3743 if (!$this->_readDataOnly) {
3745 $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3761 $recordData = substr($this->_data, $this->_pos + 4, $length);
3764 $this->_pos += 4 + $length;
3774 if (!$this->_readDataOnly) {
3775 for ($i = 0; $i < $length / 2 - 3; ++$i) {
3781 $this->_phpSheet->getCell($columnString . (
$row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3802 $recordData = substr($this->_data, $this->_pos + 4, $length);
3805 $this->_pos += 4 + $length;
3821 if ($this->_version == self::XLS_BIFF8) {
3823 $value = $string[
'value'];
3826 $value = $string[
'value'];
3828 $cell = $this->_phpSheet->getCell($columnString . (
$row + 1));
3831 if (!$this->_readDataOnly) {
3833 $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3844 $recordData = substr($this->_data, $this->_pos + 4, $length);
3847 $this->_pos += 4 + $length;
3862 if (!$this->_readDataOnly) {
3863 $this->_phpSheet->getCell($columnString . (
$row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
3878 $recordData = $splicedRecordData[
'recordData'];
3880 $this->_drawingData .= $recordData;
3889 $recordData = substr($this->_data, $this->_pos + 4, $length);
3892 $this->_pos += 4 + $length;
3894 if ($this->_readDataOnly || $this->_version != self::XLS_BIFF8) {
3913 $this->_objs[] = array(
3914 'ftCmoType' => $ftCmoType,
3915 'cbCmoSize' => $cbCmoSize,
3916 'otObjType' => $otObjType,
3917 'idObjID' => $idObjID,
3918 'grbitOpts' => $grbitOpts
3920 $this->textObjRef = $idObjID;
3933 $recordData = substr($this->_data, $this->_pos + 4, $length);
3936 $this->_pos += 4 + $length;
3942 $showGridlines = (bool) ((0x0002 & $options) >> 1);
3943 $this->_phpSheet->setShowGridlines($showGridlines);
3946 $showRowColHeaders = (bool) ((0x0004 & $options) >> 2);
3947 $this->_phpSheet->setShowRowColHeaders($showRowColHeaders);
3950 $this->_frozen = (bool) ((0x0008 & $options) >> 3);
3953 $this->_phpSheet->setRightToLeft((
bool)((0x0040 & $options) >> 6));
3956 $isActive = (bool) ((0x0400 & $options) >> 10);
3958 $this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet));
3968 $recordData = substr($this->_data, $this->_pos + 4, $length);
3971 $this->_pos += 4 + $length;
3980 $this->_phpSheet->getSheetView()->setZoomScale($numerator * 100 / $denumerator);
3989 $recordData = substr($this->_data, $this->_pos + 4, $length);
3992 $this->_pos += 4 + $length;
3994 if (!$this->_readDataOnly) {
4001 if ($this->_frozen) {
4016 $recordData = substr($this->_data, $this->_pos + 4, $length);
4019 $this->_pos += 4 + $length;
4021 if (!$this->_readDataOnly) {
4023 $paneId = ord($recordData{0});
4036 $data = substr($recordData, 7);
4039 $selectedCells = $cellRangeAddressList[
'cellRangeAddresses'][0];
4042 if (preg_match(
'/^([A-Z]+1\:[A-Z]+)16384$/', $selectedCells)) {
4043 $selectedCells = preg_replace(
'/^([A-Z]+1\:[A-Z]+)16384$/',
'${1}1048576', $selectedCells);
4047 if (preg_match(
'/^([A-Z]+1\:[A-Z]+)65536$/', $selectedCells)) {
4048 $selectedCells = preg_replace(
'/^([A-Z]+1\:[A-Z]+)65536$/',
'${1}1048576', $selectedCells);
4052 if (preg_match(
'/^(A[0-9]+\:)IV([0-9]+)$/', $selectedCells)) {
4053 $selectedCells = preg_replace(
'/^(A[0-9]+\:)IV([0-9]+)$/',
'${1}XFD${2}', $selectedCells);
4056 $this->_phpSheet->setSelectedCells($selectedCells);
4062 $includeCellRange =
true;
4064 $includeCellRange =
false;
4066 $rangeBoundaries[1][0]++;
4067 for (
$row = $rangeBoundaries[0][1];
$row <= $rangeBoundaries[1][1];
$row++) {
4068 for ($column = $rangeBoundaries[0][0]; $column != $rangeBoundaries[1][0]; $column++) {
4069 if ($this->
getReadFilter()->readCell($column,
$row, $this->_phpSheet->getTitle())) {
4070 $includeCellRange =
true;
4076 return $includeCellRange;
4091 $recordData = substr($this->_data, $this->_pos + 4, $length);
4094 $this->_pos += 4 + $length;
4096 if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
4098 foreach ($cellRangeAddressList[
'cellRangeAddresses'] as $cellRangeAddress) {
4100 $this->_phpSheet->mergeCells($cellRangeAddress);
4112 $recordData = substr($this->_data, $this->_pos + 4, $length);
4115 $this->_pos += 4 + $length;
4117 if (!$this->_readDataOnly) {
4132 $isFileLinkOrUrl = (0x00000001 &
self::_GetInt2d($recordData, 28)) >> 0;
4135 $isAbsPathOrUrl = (0x00000001 &
self::_GetInt2d($recordData, 28)) >> 1;
4157 $offset += 4 + 2 * $dl;
4161 $offset += 4 + 2 * $fl;
4165 $hyperlinkType = null;
4168 $hyperlinkType =
'UNC';
4169 }
else if (!$isFileLinkOrUrl) {
4170 $hyperlinkType =
'workbook';
4171 }
else if (ord($recordData{$offset}) == 0x03) {
4172 $hyperlinkType =
'local';
4173 }
else if (ord($recordData{$offset}) == 0xE0) {
4174 $hyperlinkType =
'URL';
4177 switch ($hyperlinkType) {
4189 $url .= $hasText ?
'#' :
'';
4211 $shortenedFilePath = substr($recordData, $offset, $sl);
4213 $shortenedFilePath = substr($shortenedFilePath, 0, -1);
4235 $extendedFilePath = substr($recordData, $offset, $xl);
4241 $url = str_repeat(
'..\\', $upLevelCount);
4243 $extendedFilePath : $shortenedFilePath;
4244 $url .= $hasText ?
'#' :
'';
4276 $this->_phpSheet->getCell($coordinate)->getHyperLink()->setUrl($url);
4287 $recordData = substr($this->_data, $this->_pos + 4, $length);
4290 $this->_pos += 4 + $length;
4299 $recordData = substr($this->_data, $this->_pos + 4, $length);
4302 $this->_pos += 4 + $length;
4304 if ($this->_readDataOnly) {
4312 $type = (0x0000000F & $options) >> 0;
4325 $errorStyle = (0x00000070 & $options) >> 4;
4326 switch ($errorStyle) {
4334 $explicitFormula = (0x00000080 & $options) >> 7;
4337 $allowBlank = (0x00000100 & $options) >> 8;
4340 $suppressDropDown = (0x00000200 & $options) >> 9;
4343 $showInputMessage = (0x00040000 & $options) >> 18;
4346 $showErrorMessage = (0x00080000 & $options) >> 19;
4349 $operator = (0x00F00000 & $options) >> 20;
4350 switch ($operator) {
4364 $promptTitle = $string[
'value'] !== chr(0) ?
4365 $string[
'value'] :
'';
4366 $offset += $string[
'size'];
4370 $errorTitle = $string[
'value'] !== chr(0) ?
4371 $string[
'value'] :
'';
4372 $offset += $string[
'size'];
4376 $prompt = $string[
'value'] !== chr(0) ?
4377 $string[
'value'] :
'';
4378 $offset += $string[
'size'];
4382 $error = $string[
'value'] !== chr(0) ?
4383 $string[
'value'] :
'';
4384 $offset += $string[
'size'];
4394 $formula1 = substr($recordData, $offset, $sz1);
4395 $formula1 = pack(
'v', $sz1) . $formula1;
4401 $formula1 = str_replace(chr(0),
',', $formula1);
4416 $formula2 = substr($recordData, $offset, $sz2);
4417 $formula2 = pack(
'v', $sz2) . $formula2;
4427 $cellRangeAddresses = $cellRangeAddressList[
'cellRangeAddresses'];
4429 foreach ($cellRangeAddresses as $cellRange) {
4430 $stRange = $this->_phpSheet->shrinkRangeToFit($cellRange);
4432 foreach ($stRange as $coordinate) {
4433 $objValidation = $this->_phpSheet->getCell($coordinate)->getDataValidation();
4434 $objValidation->setType(
$type);
4435 $objValidation->setErrorStyle($errorStyle);
4436 $objValidation->setAllowBlank((
bool)$allowBlank);
4437 $objValidation->setShowInputMessage((
bool)$showInputMessage);
4438 $objValidation->setShowErrorMessage((
bool)$showErrorMessage);
4439 $objValidation->setShowDropDown(!$suppressDropDown);
4440 $objValidation->setOperator($operator);
4441 $objValidation->setErrorTitle($errorTitle);
4442 $objValidation->setError(
$error);
4443 $objValidation->setPromptTitle($promptTitle);
4444 $objValidation->setPrompt($prompt);
4445 $objValidation->setFormula1($formula1);
4446 $objValidation->setFormula2($formula2);
4458 $recordData = substr($this->_data, $this->_pos + 4, $length);
4461 $this->_pos += 4 + $length;
4466 if (!$this->_readDataOnly) {
4480 $this->_phpSheet->getTabColor()->setRGB($color[
'rgb']);
4497 $recordData = substr($this->_data, $this->_pos + 4, $length);
4500 $this->_pos += 4 + $length;
4502 if ($this->_readDataOnly) {
4527 $bool = (0x0001 & $options) >> 0;
4528 $this->_phpSheet->getProtection()->setObjects(!$bool);
4531 $bool = (0x0002 & $options) >> 1;
4532 $this->_phpSheet->getProtection()->setScenarios(!$bool);
4535 $bool = (0x0004 & $options) >> 2;
4536 $this->_phpSheet->getProtection()->setFormatCells(!$bool);
4539 $bool = (0x0008 & $options) >> 3;
4540 $this->_phpSheet->getProtection()->setFormatColumns(!$bool);
4543 $bool = (0x0010 & $options) >> 4;
4544 $this->_phpSheet->getProtection()->setFormatRows(!$bool);
4547 $bool = (0x0020 & $options) >> 5;
4548 $this->_phpSheet->getProtection()->setInsertColumns(!$bool);
4551 $bool = (0x0040 & $options) >> 6;
4552 $this->_phpSheet->getProtection()->setInsertRows(!$bool);
4555 $bool = (0x0080 & $options) >> 7;
4556 $this->_phpSheet->getProtection()->setInsertHyperlinks(!$bool);
4559 $bool = (0x0100 & $options) >> 8;
4560 $this->_phpSheet->getProtection()->setDeleteColumns(!$bool);
4563 $bool = (0x0200 & $options) >> 9;
4564 $this->_phpSheet->getProtection()->setDeleteRows(!$bool);
4567 $bool = (0x0400 & $options) >> 10;
4568 $this->_phpSheet->getProtection()->setSelectLockedCells(!$bool);
4571 $bool = (0x0800 & $options) >> 11;
4572 $this->_phpSheet->getProtection()->setSort(!$bool);
4575 $bool = (0x1000 & $options) >> 12;
4576 $this->_phpSheet->getProtection()->setAutoFilter(!$bool);
4579 $bool = (0x2000 & $options) >> 13;
4580 $this->_phpSheet->getProtection()->setPivotTables(!$bool);
4583 $bool = (0x4000 & $options) >> 14;
4584 $this->_phpSheet->getProtection()->setSelectUnlockedCells(!$bool);
4597 $recordData = substr($this->_data, $this->_pos + 4, $length);
4600 $this->_pos += 4 + $length;
4605 if (!$this->_readDataOnly) {
4625 $cellRanges = array();
4626 for ($i = 0; $i < $cref; ++$i) {
4632 $cellRanges[] = $cellRange;
4637 $rgbFeat = substr($recordData, $offset);
4646 $this->_phpSheet->protectCells(implode(
' ', $cellRanges), strtoupper(dechex($wPassword)),
true);
4660 $recordData = $splicedRecordData[
'recordData'];
4674 $iData = substr($recordData, 8);
4691 $ih = imagecreatetruecolor($bcWidth, $bcHeight);
4699 $rgbString = substr($iData, 12);
4700 $rgbTriples = array();
4701 while (strlen($rgbString) > 0) {
4702 $rgbTriples[] = unpack(
'Cb/Cg/Cr', $rgbString);
4703 $rgbString = substr($rgbString, 3);
4707 foreach ($rgbTriples as $i => $rgbTriple) {
4708 $color = imagecolorallocate($ih, $rgbTriple[
'r'], $rgbTriple[
'g'], $rgbTriple[
'b']);
4709 imagesetpixel($ih,
$x, $bcHeight - 1 -
$y, $color);
4710 $x = (
$x + 1) % $bcWidth;
4711 $y =
$y + floor((
$x + 1) / $bcWidth);
4717 $drawing->setWorksheet($this->_phpSheet);
4739 $recordData = substr($this->_data, $this->_pos + 4, $length);
4743 if ($this->_drawingData ==
'') {
4745 $this->_pos += 4 + $length;
4753 $this->_pos += 4 + $length;
4764 $validSplitPoints = array(0xF003, 0xF004, 0xF00D);
4767 if (in_array($splitPoint, $validSplitPoints)) {
4770 $this->_drawingData .= $splicedRecordData[
'recordData'];
4776 $this->_pos += 4 + $length;
4792 $spliceOffsets = array();
4795 $spliceOffsets[0] = 0;
4804 $data .= substr($this->_data, $this->_pos + 4, $length);
4806 $spliceOffsets[$i] = $spliceOffsets[$i - 1] + $length;
4808 $this->_pos += 4 + $length;
4811 while ($nextIdentifier == self::XLS_Type_CONTINUE);
4813 $splicedData = array(
4814 'recordData' =>
$data,
4815 'spliceOffsets' => $spliceOffsets,
4818 return $splicedData;
4835 $formulaData = substr($formulaStructure, 2, $sz);
4845 if (strlen($formulaStructure) > 2 + $sz) {
4846 $additionalData = substr($formulaStructure, 2 + $sz);
4854 $additionalData =
'';
4873 while (strlen($formulaData) > 0 and $token = $this->
_getNextToken($formulaData, $baseCell)) {
4875 $formulaData = substr($formulaData, $token[
'size']);
4883 return $formulaString;
4897 if (count($tokens) == 0) {
4901 $formulaStrings = array();
4902 foreach ($tokens as $token) {
4904 $space0 = isset($space0) ? $space0 :
'';
4905 $space1 = isset($space1) ? $space1 :
'';
4906 $space2 = isset($space2) ? $space2 :
'';
4907 $space3 = isset($space3) ? $space3 :
'';
4908 $space4 = isset($space4) ? $space4 :
'';
4909 $space5 = isset($space5) ? $space5 :
'';
4911 switch ($token[
'name']) {
4927 $op2 = array_pop($formulaStrings);
4928 $op1 = array_pop($formulaStrings);
4929 $formulaStrings[] =
"$op1$space1$space0{$token['data']}$op2";
4930 unset($space0, $space1);
4934 $op = array_pop($formulaStrings);
4935 $formulaStrings[] =
"$space1$space0{$token['data']}$op";
4936 unset($space0, $space1);
4939 $op = array_pop($formulaStrings);
4940 $formulaStrings[] =
"$op$space1$space0{$token['data']}";
4941 unset($space0, $space1);
4943 case 'tAttrVolatile':
4952 switch ($token[
'data'][
'spacetype']) {
4954 $space0 = str_repeat(
' ', $token[
'data'][
'spacecount']);
4957 $space1 = str_repeat(
"\n", $token[
'data'][
'spacecount']);
4960 $space2 = str_repeat(
' ', $token[
'data'][
'spacecount']);
4963 $space3 = str_repeat(
"\n", $token[
'data'][
'spacecount']);
4966 $space4 = str_repeat(
' ', $token[
'data'][
'spacecount']);
4969 $space5 = str_repeat(
"\n", $token[
'data'][
'spacecount']);
4974 $op = array_pop($formulaStrings);
4975 $formulaStrings[] =
"{$space1}{$space0}SUM($op)";
4976 unset($space0, $space1);
4980 if ($token[
'data'][
'function'] !=
'') {
4983 for ($i = 0; $i < $token[
'data'][
'args']; ++$i) {
4984 $ops[] = array_pop($formulaStrings);
4986 $ops = array_reverse($ops);
4987 $formulaStrings[] =
"$space1$space0{$token['data']['function']}(" . implode(
',', $ops) .
")";
4988 unset($space0, $space1);
4992 for ($i = 0; $i < $token[
'data'][
'args'] - 1; ++$i) {
4993 $ops[] = array_pop($formulaStrings);
4995 $ops = array_reverse($ops);
4996 $function = array_pop($formulaStrings);
4997 $formulaStrings[] =
"$space1$space0$function(" . implode(
',', $ops) .
")";
4998 unset($space0, $space1);
5002 $expression = array_pop($formulaStrings);
5003 $formulaStrings[] =
"$space3$space2($expression$space5$space4)";
5004 unset($space2, $space3, $space4, $space5);
5008 $formulaStrings[] = $space1 . $space0 . $constantArray[
'value'];
5009 $additionalData = substr($additionalData, $constantArray[
'size']);
5010 unset($space0, $space1);
5015 $additionalData = substr($additionalData, $cellRangeAddressList[
'size']);
5016 $formulaStrings[] =
"$space1$space0{$token['data']}";
5017 unset($space0, $space1);
5035 $formulaStrings[] =
"$space1$space0{$token['data']}";
5036 unset($space0, $space1);
5040 $formulaString = $formulaStrings[0];
5046 return $formulaString;
5060 $id = ord($formulaData[0]);
5064 case 0x03:
$name =
'tAdd'; $size = 1;
$data =
'+';
break;
5065 case 0x04:
$name =
'tSub'; $size = 1;
$data =
'-';
break;
5066 case 0x05:
$name =
'tMul'; $size = 1;
$data =
'*';
break;
5067 case 0x06:
$name =
'tDiv'; $size = 1;
$data =
'/';
break;
5068 case 0x07:
$name =
'tPower'; $size = 1;
$data =
'^';
break;
5069 case 0x08:
$name =
'tConcat'; $size = 1;
$data =
'&';
break;
5070 case 0x09:
$name =
'tLT'; $size = 1;
$data =
'<';
break;
5071 case 0x0A:
$name =
'tLE'; $size = 1;
$data =
'<=';
break;
5072 case 0x0B:
$name =
'tEQ'; $size = 1;
$data =
'=';
break;
5073 case 0x0C:
$name =
'tGE'; $size = 1;
$data =
'>=';
break;
5074 case 0x0D:
$name =
'tGT'; $size = 1;
$data =
'>';
break;
5075 case 0x0E:
$name =
'tNE'; $size = 1;
$data =
'<>';
break;
5076 case 0x0F:
$name =
'tIsect'; $size = 1;
$data =
' ';
break;
5077 case 0x10:
$name =
'tList'; $size = 1;
$data =
',';
break;
5078 case 0x11:
$name =
'tRange'; $size = 1;
$data =
':';
break;
5079 case 0x12:
$name =
'tUplus'; $size = 1;
$data =
'+';
break;
5080 case 0x13:
$name =
'tUminus'; $size = 1;
$data =
'-';
break;
5081 case 0x14:
$name =
'tPercent'; $size = 1;
$data =
'%';
break;
5096 $size = 1 + $string[
'size'];
5101 switch (ord($formulaData[1])) {
5103 $name =
'tAttrVolatile';
5113 $name =
'tAttrChoose';
5118 $size = 2 * $nc + 6;
5122 $name =
'tAttrSkip';
5133 $name =
'tAttrSpace';
5136 switch (ord($formulaData[2])) {
5138 $spacetype =
'type0';
5141 $spacetype =
'type1';
5144 $spacetype =
'type2';
5147 $spacetype =
'type3';
5150 $spacetype =
'type4';
5153 $spacetype =
'type5';
5156 throw new Exception(
'Unrecognized space type in tAttrSpace token');
5160 $spacecount = ord($formulaData[3]);
5162 $data = array(
'spacetype' => $spacetype,
'spacecount' => $spacecount);
5165 throw new Exception(
'Unrecognized attribute flag in tAttr token');
5179 $data = ord($formulaData[1]) ?
'TRUE' :
'FALSE';
5192 $data = str_replace(
',',
'.', (
string)
$data);
5208 switch (self::_GetInt2d($formulaData, 1)) {
5209 case 2: $function =
'ISNA'; $args = 1;
break;
5210 case 3: $function =
'ISERROR'; $args = 1;
break;
5211 case 10: $function =
'NA'; $args = 0;
break;
5212 case 15: $function =
'SIN'; $args = 1;
break;
5213 case 16: $function =
'COS'; $args = 1;
break;
5214 case 17: $function =
'TAN'; $args = 1;
break;
5215 case 18: $function =
'ATAN'; $args = 1;
break;
5216 case 19: $function =
'PI'; $args = 0;
break;
5217 case 20: $function =
'SQRT'; $args = 1;
break;
5218 case 21: $function =
'EXP'; $args = 1;
break;
5219 case 22: $function =
'LN'; $args = 1;
break;
5220 case 23: $function =
'LOG10'; $args = 1;
break;
5221 case 24: $function =
'ABS'; $args = 1;
break;
5222 case 25: $function =
'INT'; $args = 1;
break;
5223 case 26: $function =
'SIGN'; $args = 1;
break;
5224 case 27: $function =
'ROUND'; $args = 2;
break;
5225 case 30: $function =
'REPT'; $args = 2;
break;
5226 case 31: $function =
'MID'; $args = 3;
break;
5227 case 32: $function =
'LEN'; $args = 1;
break;
5228 case 33: $function =
'VALUE'; $args = 1;
break;
5229 case 34: $function =
'TRUE'; $args = 0;
break;
5230 case 35: $function =
'FALSE'; $args = 0;
break;
5231 case 38: $function =
'NOT'; $args = 1;
break;
5232 case 39: $function =
'MOD'; $args = 2;
break;
5233 case 40: $function =
'DCOUNT'; $args = 3;
break;
5234 case 41: $function =
'DSUM'; $args = 3;
break;
5235 case 42: $function =
'DAVERAGE'; $args = 3;
break;
5236 case 43: $function =
'DMIN'; $args = 3;
break;
5237 case 44: $function =
'DMAX'; $args = 3;
break;
5238 case 45: $function =
'DSTDEV'; $args = 3;
break;
5239 case 48: $function =
'TEXT'; $args = 2;
break;
5240 case 61: $function =
'MIRR'; $args = 3;
break;
5241 case 63: $function =
'RAND'; $args = 0;
break;
5242 case 65: $function =
'DATE'; $args = 3;
break;
5243 case 66: $function =
'TIME'; $args = 3;
break;
5244 case 67: $function =
'DAY'; $args = 1;
break;
5245 case 68: $function =
'MONTH'; $args = 1;
break;
5246 case 69: $function =
'YEAR'; $args = 1;
break;
5247 case 71: $function =
'HOUR'; $args = 1;
break;
5248 case 72: $function =
'MINUTE'; $args = 1;
break;
5249 case 73: $function =
'SECOND'; $args = 1;
break;
5250 case 74: $function =
'NOW'; $args = 0;
break;
5251 case 75: $function =
'AREAS'; $args = 1;
break;
5252 case 76: $function =
'ROWS'; $args = 1;
break;
5253 case 77: $function =
'COLUMNS'; $args = 1;
break;
5254 case 83: $function =
'TRANSPOSE'; $args = 1;
break;
5255 case 86: $function =
'TYPE'; $args = 1;
break;
5256 case 97: $function =
'ATAN2'; $args = 2;
break;
5257 case 98: $function =
'ASIN'; $args = 1;
break;
5258 case 99: $function =
'ACOS'; $args = 1;
break;
5259 case 105: $function =
'ISREF'; $args = 1;
break;
5260 case 111: $function =
'CHAR'; $args = 1;
break;
5261 case 112: $function =
'LOWER'; $args = 1;
break;
5262 case 113: $function =
'UPPER'; $args = 1;
break;
5263 case 114: $function =
'PROPER'; $args = 1;
break;
5264 case 117: $function =
'EXACT'; $args = 2;
break;
5265 case 118: $function =
'TRIM'; $args = 1;
break;
5266 case 119: $function =
'REPLACE'; $args = 4;
break;
5267 case 121: $function =
'CODE'; $args = 1;
break;
5268 case 126: $function =
'ISERR'; $args = 1;
break;
5269 case 127: $function =
'ISTEXT'; $args = 1;
break;
5270 case 128: $function =
'ISNUMBER'; $args = 1;
break;
5271 case 129: $function =
'ISBLANK'; $args = 1;
break;
5272 case 130: $function =
'T'; $args = 1;
break;
5273 case 131: $function =
'N'; $args = 1;
break;
5274 case 140: $function =
'DATEVALUE'; $args = 1;
break;
5275 case 141: $function =
'TIMEVALUE'; $args = 1;
break;
5276 case 142: $function =
'SLN'; $args = 3;
break;
5277 case 143: $function =
'SYD'; $args = 4;
break;
5278 case 162: $function =
'CLEAN'; $args = 1;
break;
5279 case 163: $function =
'MDETERM'; $args = 1;
break;
5280 case 164: $function =
'MINVERSE'; $args = 1;
break;
5281 case 165: $function =
'MMULT'; $args = 2;
break;
5282 case 184: $function =
'FACT'; $args = 1;
break;
5283 case 189: $function =
'DPRODUCT'; $args = 3;
break;
5284 case 190: $function =
'ISNONTEXT'; $args = 1;
break;
5285 case 195: $function =
'DSTDEVP'; $args = 3;
break;
5286 case 196: $function =
'DVARP'; $args = 3;
break;
5287 case 198: $function =
'ISLOGICAL'; $args = 1;
break;
5288 case 199: $function =
'DCOUNTA'; $args = 3;
break;
5289 case 207: $function =
'REPLACEB'; $args = 4;
break;
5290 case 210: $function =
'MIDB'; $args = 3;
break;
5291 case 211: $function =
'LENB'; $args = 1;
break;
5292 case 212: $function =
'ROUNDUP'; $args = 2;
break;
5293 case 213: $function =
'ROUNDDOWN'; $args = 2;
break;
5294 case 214: $function =
'ASC'; $args = 1;
break;
5295 case 215: $function =
'DBCS'; $args = 1;
break;
5296 case 221: $function =
'TODAY'; $args = 0;
break;
5297 case 229: $function =
'SINH'; $args = 1;
break;
5298 case 230: $function =
'COSH'; $args = 1;
break;
5299 case 231: $function =
'TANH'; $args = 1;
break;
5300 case 232: $function =
'ASINH'; $args = 1;
break;
5301 case 233: $function =
'ACOSH'; $args = 1;
break;
5302 case 234: $function =
'ATANH'; $args = 1;
break;
5303 case 235: $function =
'DGET'; $args = 3;
break;
5304 case 244: $function =
'INFO'; $args = 1;
break;
5305 case 252: $function =
'FREQUENCY'; $args = 2;
break;
5306 case 261: $function =
'ERROR.TYPE'; $args = 1;
break;
5307 case 271: $function =
'GAMMALN'; $args = 1;
break;
5308 case 273: $function =
'BINOMDIST'; $args = 4;
break;
5309 case 274: $function =
'CHIDIST'; $args = 2;
break;
5310 case 275: $function =
'CHIINV'; $args = 2;
break;
5311 case 276: $function =
'COMBIN'; $args = 2;
break;
5312 case 277: $function =
'CONFIDENCE'; $args = 3;
break;
5313 case 278: $function =
'CRITBINOM'; $args = 3;
break;
5314 case 279: $function =
'EVEN'; $args = 1;
break;
5315 case 280: $function =
'EXPONDIST'; $args = 3;
break;
5316 case 281: $function =
'FDIST'; $args = 3;
break;
5317 case 282: $function =
'FINV'; $args = 3;
break;
5318 case 283: $function =
'FISHER'; $args = 1;
break;
5319 case 284: $function =
'FISHERINV'; $args = 1;
break;
5320 case 285: $function =
'FLOOR'; $args = 2;
break;
5321 case 286: $function =
'GAMMADIST'; $args = 4;
break;
5322 case 287: $function =
'GAMMAINV'; $args = 3;
break;
5323 case 288: $function =
'CEILING'; $args = 2;
break;
5324 case 289: $function =
'HYPGEOMDIST'; $args = 4;
break;
5325 case 290: $function =
'LOGNORMDIST'; $args = 3;
break;
5326 case 291: $function =
'LOGINV'; $args = 3;
break;
5327 case 292: $function =
'NEGBINOMDIST'; $args = 3;
break;
5328 case 293: $function =
'NORMDIST'; $args = 4;
break;
5329 case 294: $function =
'NORMSDIST'; $args = 1;
break;
5330 case 295: $function =
'NORMINV'; $args = 3;
break;
5331 case 296: $function =
'NORMSINV'; $args = 1;
break;
5332 case 297: $function =
'STANDARDIZE'; $args = 3;
break;
5333 case 298: $function =
'ODD'; $args = 1;
break;
5334 case 299: $function =
'PERMUT'; $args = 2;
break;
5335 case 300: $function =
'POISSON'; $args = 3;
break;
5336 case 301: $function =
'TDIST'; $args = 3;
break;
5337 case 302: $function =
'WEIBULL'; $args = 4;
break;
5338 case 303: $function =
'SUMXMY2'; $args = 2;
break;
5339 case 304: $function =
'SUMX2MY2'; $args = 2;
break;
5340 case 305: $function =
'SUMX2PY2'; $args = 2;
break;
5341 case 306: $function =
'CHITEST'; $args = 2;
break;
5342 case 307: $function =
'CORREL'; $args = 2;
break;
5343 case 308: $function =
'COVAR'; $args = 2;
break;
5344 case 309: $function =
'FORECAST'; $args = 3;
break;
5345 case 310: $function =
'FTEST'; $args = 2;
break;
5346 case 311: $function =
'INTERCEPT'; $args = 2;
break;
5347 case 312: $function =
'PEARSON'; $args = 2;
break;
5348 case 313: $function =
'RSQ'; $args = 2;
break;
5349 case 314: $function =
'STEYX'; $args = 2;
break;
5350 case 315: $function =
'SLOPE'; $args = 2;
break;
5351 case 316: $function =
'TTEST'; $args = 4;
break;
5352 case 325: $function =
'LARGE'; $args = 2;
break;
5353 case 326: $function =
'SMALL'; $args = 2;
break;
5354 case 327: $function =
'QUARTILE'; $args = 2;
break;
5355 case 328: $function =
'PERCENTILE'; $args = 2;
break;
5356 case 331: $function =
'TRIMMEAN'; $args = 2;
break;
5357 case 332: $function =
'TINV'; $args = 2;
break;
5358 case 337: $function =
'POWER'; $args = 2;
break;
5359 case 342: $function =
'RADIANS'; $args = 1;
break;
5360 case 343: $function =
'DEGREES'; $args = 1;
break;
5361 case 346: $function =
'COUNTIF'; $args = 2;
break;
5362 case 347: $function =
'COUNTBLANK'; $args = 1;
break;
5363 case 350: $function =
'ISPMT'; $args = 4;
break;
5364 case 351: $function =
'DATEDIF'; $args = 3;
break;
5365 case 352: $function =
'DATESTRING'; $args = 1;
break;
5366 case 353: $function =
'NUMBERSTRING'; $args = 2;
break;
5367 case 360: $function =
'PHONETIC'; $args = 1;
break;
5368 case 368: $function =
'BAHTTEXT'; $args = 1;
break;
5370 throw new Exception(
'Unrecognized function in formula');
5373 $data = array(
'function' => $function,
'args' => $args);
5381 $args = ord($formulaData[1]);
5385 case 0: $function =
'COUNT';
break;
5386 case 1: $function =
'IF';
break;
5387 case 4: $function =
'SUM';
break;
5388 case 5: $function =
'AVERAGE';
break;
5389 case 6: $function =
'MIN';
break;
5390 case 7: $function =
'MAX';
break;
5391 case 8: $function =
'ROW';
break;
5392 case 9: $function =
'COLUMN';
break;
5393 case 11: $function =
'NPV';
break;
5394 case 12: $function =
'STDEV';
break;
5395 case 13: $function =
'DOLLAR';
break;
5396 case 14: $function =
'FIXED';
break;
5397 case 28: $function =
'LOOKUP';
break;
5398 case 29: $function =
'INDEX';
break;
5399 case 36: $function =
'AND';
break;
5400 case 37: $function =
'OR';
break;
5401 case 46: $function =
'VAR';
break;
5402 case 49: $function =
'LINEST';
break;
5403 case 50: $function =
'TREND';
break;
5404 case 51: $function =
'LOGEST';
break;
5405 case 52: $function =
'GROWTH';
break;
5406 case 56: $function =
'PV';
break;
5407 case 57: $function =
'FV';
break;
5408 case 58: $function =
'NPER';
break;
5409 case 59: $function =
'PMT';
break;
5410 case 60: $function =
'RATE';
break;
5411 case 62: $function =
'IRR';
break;
5412 case 64: $function =
'MATCH';
break;
5413 case 70: $function =
'WEEKDAY';
break;
5414 case 78: $function =
'OFFSET';
break;
5415 case 82: $function =
'SEARCH';
break;
5416 case 100: $function =
'CHOOSE';
break;
5417 case 101: $function =
'HLOOKUP';
break;
5418 case 102: $function =
'VLOOKUP';
break;
5419 case 109: $function =
'LOG';
break;
5420 case 115: $function =
'LEFT';
break;
5421 case 116: $function =
'RIGHT';
break;
5422 case 120: $function =
'SUBSTITUTE';
break;
5423 case 124: $function =
'FIND';
break;
5424 case 125: $function =
'CELL';
break;
5425 case 144: $function =
'DDB';
break;
5426 case 148: $function =
'INDIRECT';
break;
5427 case 167: $function =
'IPMT';
break;
5428 case 168: $function =
'PPMT';
break;
5429 case 169: $function =
'COUNTA';
break;
5430 case 183: $function =
'PRODUCT';
break;
5431 case 193: $function =
'STDEVP';
break;
5432 case 194: $function =
'VARP';
break;
5433 case 197: $function =
'TRUNC';
break;
5434 case 204: $function =
'USDOLLAR';
break;
5435 case 205: $function =
'FINDB';
break;
5436 case 206: $function =
'SEARCHB';
break;
5437 case 208: $function =
'LEFTB';
break;
5438 case 209: $function =
'RIGHTB';
break;
5439 case 216: $function =
'RANK';
break;
5440 case 219: $function =
'ADDRESS';
break;
5441 case 220: $function =
'DAYS360';
break;
5442 case 222: $function =
'VDB';
break;
5443 case 227: $function =
'MEDIAN';
break;
5444 case 228: $function =
'SUMPRODUCT';
break;
5445 case 247: $function =
'DB';
break;
5446 case 255: $function =
'';
break;
5447 case 269: $function =
'AVEDEV';
break;
5448 case 270: $function =
'BETADIST';
break;
5449 case 272: $function =
'BETAINV';
break;
5450 case 317: $function =
'PROB';
break;
5451 case 318: $function =
'DEVSQ';
break;
5452 case 319: $function =
'GEOMEAN';
break;
5453 case 320: $function =
'HARMEAN';
break;
5454 case 321: $function =
'SUMSQ';
break;
5455 case 322: $function =
'KURT';
break;
5456 case 323: $function =
'SKEW';
break;
5457 case 324: $function =
'ZTEST';
break;
5458 case 329: $function =
'PERCENTRANK';
break;
5459 case 330: $function =
'MODE';
break;
5460 case 336: $function =
'CONCATENATE';
break;
5461 case 344: $function =
'SUBTOTAL';
break;
5462 case 345: $function =
'SUMIF';
break;
5463 case 354: $function =
'ROMAN';
break;
5464 case 358: $function =
'GETPIVOTDATA';
break;
5465 case 359: $function =
'HYPERLINK';
break;
5466 case 361: $function =
'AVERAGEA';
break;
5467 case 362: $function =
'MAXA';
break;
5468 case 363: $function =
'MINA';
break;
5469 case 364: $function =
'STDEVPA';
break;
5470 case 365: $function =
'VARPA';
break;
5471 case 366: $function =
'STDEVA';
break;
5472 case 367: $function =
'VARA';
break;
5474 throw new Exception(
'Unrecognized function in formula');
5477 $data = array(
'function' => $function,
'args' => $args);
5487 $data = $this->_definedname[$definedNameIndex][
'name'];
5510 $size = 7 + $subSize;
5520 $size = 7 + $subSize;
5529 $size = 3 + $subSize;
5558 $data = $this->_externalNames[$index - 1][
'name'];
5574 $data =
"$sheetRange!$cellAddress";
5593 $data =
"$sheetRange!$cellRangeAddress";
5602 throw new Exception(
'Unrecognized token ' . sprintf(
'%02X', $id) .
' in formula');
5632 if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) {
5633 $column =
'$' . $column;
5636 if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) {
5640 return $column .
$row;
5667 if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) {
5669 $column =
'$' . $column;
5671 $colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256;
5676 if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) {
5679 $rowIndex = ($rowIndex <= 32767) ? $rowIndex : $rowIndex - 65536;
5680 $row = $baseRow + $rowIndex;
5683 return $column .
$row;
5704 $fc = ord($subData{4});
5707 $lc = ord($subData{5});
5710 if ($fr > $lr || $fc > $lc) {
5711 throw new Exception(
'Not a cell range address');
5718 if ($fr == $lr and $fc == $lc) {
5721 return "$fc$fr:$lc$lr";
5748 if ($fr > $lr || $fc > $lc) {
5749 throw new Exception(
'Not a cell range address');
5756 if ($fr == $lr and $fc == $lc) {
5759 return "$fc$fr:$lc$lr";
5787 if (!(0x4000 & self::_GetInt2d($subData, 4))) {
5792 if (!(0x8000 & self::_GetInt2d($subData, 4))) {
5802 if (!(0x4000 & self::_GetInt2d($subData, 6))) {
5807 if (!(0x8000 & self::_GetInt2d($subData, 6))) {
5811 return "$fc$fr:$lc$lr";
5843 if (!(0x4000 & self::_GetInt2d($subData, 4))) {
5849 $fcIndex = ($fcIndex <= 127) ? $fcIndex : $fcIndex - 256;
5854 if (!(0x8000 & self::_GetInt2d($subData, 4))) {
5860 $frIndex = ($frIndex <= 32767) ? $frIndex : $frIndex - 65536;
5861 $fr = $baseRow + $frIndex;
5868 $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
5872 if (!(0x4000 & self::_GetInt2d($subData, 6))) {
5878 $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
5883 if (!(0x8000 & self::_GetInt2d($subData, 6))) {
5889 $lrIndex = ($lrIndex <= 32767) ? $lrIndex : $lrIndex - 65536;
5890 $lr = $baseRow + $lrIndex;
5893 return "$fc$fr:$lc$lr";
5905 $cellRangeAddresses = array();
5912 for ($i = 0; $i < $nm; ++$i) {
5918 'size' => 2 + 8 * $nm,
5919 'cellRangeAddresses' => $cellRangeAddresses,
5932 $cellRangeAddresses = array();
5939 for ($i = 0; $i < $nm; ++$i) {
5945 'size' => 2 + 6 * $nm,
5946 'cellRangeAddresses' => $cellRangeAddresses,
5962 if (isset($this->_ref[$index])) {
5964 $type = $this->_externalBooks[$this->_ref[$index][
'externalBookIndex']][
'type'];
5969 if ($this->_ref[$index][
'firstSheetIndex'] == 0xFFFF or $this->_ref[$index][
'lastSheetIndex'] == 0xFFFF) {
5970 throw new Exception(
'Deleted sheet reference');
5974 $firstSheetName = $this->_sheets[$this->_ref[$index][
'firstSheetIndex']][
'name'];
5975 $lastSheetName = $this->_sheets[$this->_ref[$index][
'lastSheetIndex']][
'name'];
5977 if ($firstSheetName == $lastSheetName) {
5979 $sheetRange = $firstSheetName;
5981 $sheetRange =
"$firstSheetName:$lastSheetName";
5985 $sheetRange = str_replace(
"'",
"''", $sheetRange);
5991 if (preg_match(
"/[ !\"@#£$%&{()}<>=+'|^,;-]/", $sheetRange)) {
5992 $sheetRange =
"'$sheetRange'";
6000 throw new Exception(
'Excel5 reader only supports internal sheets in fomulas');
6018 $nc = ord($arrayData[0]);
6023 $arrayData = substr($arrayData, 3);
6026 $matrixChunks = array();
6027 for ($r = 1; $r <= $nr + 1; ++$r) {
6029 for ($c = 1; $c <= $nc + 1; ++$c) {
6031 $items[] = $constant[
'value'];
6032 $arrayData = substr($arrayData, $constant[
'size']);
6033 $size += $constant[
'size'];
6035 $matrixChunks[] = implode(
',', $items);
6037 $matrix =
'{' . implode(
';', $matrixChunks) .
'}';
6056 $identifier = ord($valueData[0]);
6058 switch ($identifier) {
6071 $value =
'"' . $string[
'value'] .
'"';
6072 $size = 1 + $string[
'size'];
6076 if (ord($valueData[1])) {
6114 $rgb = sprintf(
'%02X%02X%02X', $r, $g, $b);
6116 return array(
'rgb' => $rgb);
6129 $ln = ord($subData[0]);
6175 $characterCount = ord($subData[0]);
6180 $string[
'size'] += 1;
6203 $string[
'size'] += 2;
6224 $isCompressed = !((0x01 & ord($subData[0])) >> 0);
6227 $hasAsian = (0x04) & ord($subData[0]) >> 2;
6230 $hasRichText = (0x08) & ord($subData[0]) >> 3;
6235 $value =
self::_encodeUTF16(substr($subData, 1, $isCompressed ? $characterCount : 2 * $characterCount), $isCompressed);
6239 'size' => $isCompressed ? 1 + $characterCount : 1 + 2 * $characterCount,
6252 return '"' . str_replace(
'"',
'""', $value) .
'"';
6265 $sign = ($rknumhigh & 0x80000000) >> 31;
6266 $exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023;
6267 $mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
6268 $mantissalow1 = ($rknumlow & 0x80000000) >> 31;
6269 $mantissalow2 = ($rknumlow & 0x7fffffff);
6270 $value = $mantissa / pow( 2 , (20 - $exp));
6272 if ($mantissalow1 != 0) {
6273 $value += 1 / pow (2 , (21 - $exp));
6276 $value += $mantissalow2 / pow (2 , (52 - $exp));
6278 $value = -1 * $value;
6286 if (($rknum & 0x02) != 0) {
6287 $value = $rknum >> 2;
6295 $sign = ($rknum & 0x80000000) >> 31;
6296 $exp = ($rknum & 0x7ff00000) >> 20;
6297 $mantissa = (0x100000 | ($rknum & 0x000ffffc));
6298 $value = $mantissa / pow( 2 , (20- ($exp - 1023)));
6300 $value = -1 * $value;
6304 if (($rknum & 0x01) != 0) {
6334 $uncompressedString =
'';
6335 $strLen = strlen($string);
6336 for ($i = 0; $i < $strLen; ++$i) {
6337 $uncompressedString .= $string[$i] .
"\0";
6340 return $uncompressedString;
6379 if ($_or_24 >= 128) {
6381 $_ord_24 = -abs((256 - $_or_24) << 24);
6383 $_ord_24 = ($_or_24 & 127) << 24;
6385 return ord(
$data[
$pos]) | (ord(
$data[$pos + 1]) << 8) | (ord(
$data[$pos + 2]) << 16) | $_ord_24;
6397 if ($color <= 0x07 || $color >= 0x40) {
6400 } elseif (isset($palette) && isset($palette[$color - 8])) {
6402 return $palette[$color - 8];
6405 if ($version == self::XLS_BIFF8) {
6487 case 0x00:
return '#NULL!';
break;
6488 case 0x07:
return '#DIV/0!';
break;
6489 case 0x0F:
return '#VALUE!';
break;
6490 case 0x17:
return '#REF!';
break;
6491 case 0x1D:
return '#NAME?';
break;
6492 case 0x24:
return '#NUM!';
break;
6493 case 0x2A:
return '#N/A';
break;
6494 default:
return false;
6507 case 0x00:
return array(
'rgb' =>
'000000');
6508 case 0x01:
return array(
'rgb' =>
'FFFFFF');
6509 case 0x02:
return array(
'rgb' =>
'FF0000');
6510 case 0x03:
return array(
'rgb' =>
'00FF00');
6511 case 0x04:
return array(
'rgb' =>
'0000FF');
6512 case 0x05:
return array(
'rgb' =>
'FFFF00');
6513 case 0x06:
return array(
'rgb' =>
'FF00FF');
6514 case 0x07:
return array(
'rgb' =>
'00FFFF');
6515 case 0x40:
return array(
'rgb' =>
'000000');
6516 case 0x41:
return array(
'rgb' =>
'FFFFFF');
6517 default:
return array(
'rgb' =>
'000000');
6530 case 0x08:
return array(
'rgb' =>
'000000');
6531 case 0x09:
return array(
'rgb' =>
'FFFFFF');
6532 case 0x0A:
return array(
'rgb' =>
'FF0000');
6533 case 0x0B:
return array(
'rgb' =>
'00FF00');
6534 case 0x0C:
return array(
'rgb' =>
'0000FF');
6535 case 0x0D:
return array(
'rgb' =>
'FFFF00');
6536 case 0x0E:
return array(
'rgb' =>
'FF00FF');
6537 case 0x0F:
return array(
'rgb' =>
'00FFFF');
6538 case 0x10:
return array(
'rgb' =>
'800000');
6539 case 0x11:
return array(
'rgb' =>
'008000');
6540 case 0x12:
return array(
'rgb' =>
'000080');
6541 case 0x13:
return array(
'rgb' =>
'808000');
6542 case 0x14:
return array(
'rgb' =>
'800080');
6543 case 0x15:
return array(
'rgb' =>
'008080');
6544 case 0x16:
return array(
'rgb' =>
'C0C0C0');
6545 case 0x17:
return array(
'rgb' =>
'808080');
6546 case 0x18:
return array(
'rgb' =>
'8080FF');
6547 case 0x19:
return array(
'rgb' =>
'802060');
6548 case 0x1A:
return array(
'rgb' =>
'FFFFC0');
6549 case 0x1B:
return array(
'rgb' =>
'A0E0F0');
6550 case 0x1C:
return array(
'rgb' =>
'600080');
6551 case 0x1D:
return array(
'rgb' =>
'FF8080');
6552 case 0x1E:
return array(
'rgb' =>
'0080C0');
6553 case 0x1F:
return array(
'rgb' =>
'C0C0FF');
6554 case 0x20:
return array(
'rgb' =>
'000080');
6555 case 0x21:
return array(
'rgb' =>
'FF00FF');
6556 case 0x22:
return array(
'rgb' =>
'FFFF00');
6557 case 0x23:
return array(
'rgb' =>
'00FFFF');
6558 case 0x24:
return array(
'rgb' =>
'800080');
6559 case 0x25:
return array(
'rgb' =>
'800000');
6560 case 0x26:
return array(
'rgb' =>
'008080');
6561 case 0x27:
return array(
'rgb' =>
'0000FF');
6562 case 0x28:
return array(
'rgb' =>
'00CFFF');
6563 case 0x29:
return array(
'rgb' =>
'69FFFF');
6564 case 0x2A:
return array(
'rgb' =>
'E0FFE0');
6565 case 0x2B:
return array(
'rgb' =>
'FFFF80');
6566 case 0x2C:
return array(
'rgb' =>
'A6CAF0');
6567 case 0x2D:
return array(
'rgb' =>
'DD9CB3');
6568 case 0x2E:
return array(
'rgb' =>
'B38FEE');
6569 case 0x2F:
return array(
'rgb' =>
'E3E3E3');
6570 case 0x30:
return array(
'rgb' =>
'2A6FF9');
6571 case 0x31:
return array(
'rgb' =>
'3FB8CD');
6572 case 0x32:
return array(
'rgb' =>
'488436');
6573 case 0x33:
return array(
'rgb' =>
'958C41');
6574 case 0x34:
return array(
'rgb' =>
'8E5E42');
6575 case 0x35:
return array(
'rgb' =>
'A0627A');
6576 case 0x36:
return array(
'rgb' =>
'624FAC');
6577 case 0x37:
return array(
'rgb' =>
'969696');
6578 case 0x38:
return array(
'rgb' =>
'1D2FBE');
6579 case 0x39:
return array(
'rgb' =>
'286676');
6580 case 0x3A:
return array(
'rgb' =>
'004500');
6581 case 0x3B:
return array(
'rgb' =>
'453E01');
6582 case 0x3C:
return array(
'rgb' =>
'6A2813');
6583 case 0x3D:
return array(
'rgb' =>
'85396A');
6584 case 0x3E:
return array(
'rgb' =>
'4A3285');
6585 case 0x3F:
return array(
'rgb' =>
'424242');
6586 default:
return array(
'rgb' =>
'000000');
6599 case 0x08:
return array(
'rgb' =>
'000000');
6600 case 0x09:
return array(
'rgb' =>
'FFFFFF');
6601 case 0x0A:
return array(
'rgb' =>
'FF0000');
6602 case 0x0B:
return array(
'rgb' =>
'00FF00');
6603 case 0x0C:
return array(
'rgb' =>
'0000FF');
6604 case 0x0D:
return array(
'rgb' =>
'FFFF00');
6605 case 0x0E:
return array(
'rgb' =>
'FF00FF');
6606 case 0x0F:
return array(
'rgb' =>
'00FFFF');
6607 case 0x10:
return array(
'rgb' =>
'800000');
6608 case 0x11:
return array(
'rgb' =>
'008000');
6609 case 0x12:
return array(
'rgb' =>
'000080');
6610 case 0x13:
return array(
'rgb' =>
'808000');
6611 case 0x14:
return array(
'rgb' =>
'800080');
6612 case 0x15:
return array(
'rgb' =>
'008080');
6613 case 0x16:
return array(
'rgb' =>
'C0C0C0');
6614 case 0x17:
return array(
'rgb' =>
'808080');
6615 case 0x18:
return array(
'rgb' =>
'9999FF');
6616 case 0x19:
return array(
'rgb' =>
'993366');
6617 case 0x1A:
return array(
'rgb' =>
'FFFFCC');
6618 case 0x1B:
return array(
'rgb' =>
'CCFFFF');
6619 case 0x1C:
return array(
'rgb' =>
'660066');
6620 case 0x1D:
return array(
'rgb' =>
'FF8080');
6621 case 0x1E:
return array(
'rgb' =>
'0066CC');
6622 case 0x1F:
return array(
'rgb' =>
'CCCCFF');
6623 case 0x20:
return array(
'rgb' =>
'000080');
6624 case 0x21:
return array(
'rgb' =>
'FF00FF');
6625 case 0x22:
return array(
'rgb' =>
'FFFF00');
6626 case 0x23:
return array(
'rgb' =>
'00FFFF');
6627 case 0x24:
return array(
'rgb' =>
'800080');
6628 case 0x25:
return array(
'rgb' =>
'800000');
6629 case 0x26:
return array(
'rgb' =>
'008080');
6630 case 0x27:
return array(
'rgb' =>
'0000FF');
6631 case 0x28:
return array(
'rgb' =>
'00CCFF');
6632 case 0x29:
return array(
'rgb' =>
'CCFFFF');
6633 case 0x2A:
return array(
'rgb' =>
'CCFFCC');
6634 case 0x2B:
return array(
'rgb' =>
'FFFF99');
6635 case 0x2C:
return array(
'rgb' =>
'99CCFF');
6636 case 0x2D:
return array(
'rgb' =>
'FF99CC');
6637 case 0x2E:
return array(
'rgb' =>
'CC99FF');
6638 case 0x2F:
return array(
'rgb' =>
'FFCC99');
6639 case 0x30:
return array(
'rgb' =>
'3366FF');
6640 case 0x31:
return array(
'rgb' =>
'33CCCC');
6641 case 0x32:
return array(
'rgb' =>
'99CC00');
6642 case 0x33:
return array(
'rgb' =>
'FFCC00');
6643 case 0x34:
return array(
'rgb' =>
'FF9900');
6644 case 0x35:
return array(
'rgb' =>
'FF6600');
6645 case 0x36:
return array(
'rgb' =>
'666699');
6646 case 0x37:
return array(
'rgb' =>
'969696');
6647 case 0x38:
return array(
'rgb' =>
'003366');
6648 case 0x39:
return array(
'rgb' =>
'339966');
6649 case 0x3A:
return array(
'rgb' =>
'003300');
6650 case 0x3B:
return array(
'rgb' =>
'333300');
6651 case 0x3C:
return array(
'rgb' =>
'993300');
6652 case 0x3D:
return array(
'rgb' =>
'993366');
6653 case 0x3E:
return array(
'rgb' =>
'333399');
6654 case 0x3F:
return array(
'rgb' =>
'333333');
6655 default:
return array(
'rgb' =>
'000000');
6662 $value->createText($is);