148 $this->defaultFont = $this->spreadsheet->getDefaultStyle()->getFont();
156 public function save($pFilename): void
162 fwrite($this->fileHandle, $this->generateHTMLAll());
176 $this->spreadsheet->garbageCollect();
184 $this->
buildCSS(!$this->useInlineCss);
192 if ((!$this->isPdf) && ($this->generateSheetNavigationBlock)) {
220 $this->editHtmlCallback = $callback;
239 return array_key_exists($vAlign, self::VALIGN_ARR) ? self::VALIGN_ARR[$vAlign] :
'baseline';
259 return array_key_exists($hAlign, self::HALIGN_ARR) ? self::HALIGN_ARR[$hAlign] :
'';
286 return array_key_exists($borderStyle, self::BORDER_ARR) ? self::BORDER_ARR[$borderStyle] :
'1px solid';
308 $this->sheetIndex = $pValue;
332 $this->generateSheetNavigationBlock = (bool) $pValue;
344 $this->sheetIndex =
null;
351 return $val ? (
' <meta name="' . $desc .
'" content="' . htmlspecialchars($val) .
'" />' .
PHP_EOL) :
'';
364 $properties = $this->spreadsheet->getProperties();
365 $html =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' .
PHP_EOL;
366 $html .=
'<html xmlns="http://www.w3.org/1999/xhtml">' .
PHP_EOL;
368 $html .=
' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' .
PHP_EOL;
369 $html .=
' <meta name="generator" content="PhpSpreadsheet, https://github.com/PHPOffice/PhpSpreadsheet" />' .
PHP_EOL;
370 $html .=
' <title>' . htmlspecialchars($properties->getTitle()) .
'</title>' .
PHP_EOL;
395 if ($this->sheetIndex ===
null) {
396 $sheets = $this->spreadsheet->getAllSheets();
398 $sheets = [$this->spreadsheet->getSheet($this->sheetIndex)];
407 $tbodyStart = $rowMin;
408 $theadStart = $theadEnd = 0;
409 if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
410 $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
413 if ($rowsToRepeatAtTop[0] == 1) {
414 $theadStart = $rowsToRepeatAtTop[0];
415 $theadEnd = $rowsToRepeatAtTop[1];
416 $tbodyStart = $rowsToRepeatAtTop[1] + 1;
420 return [$theadStart, $theadEnd, $tbodyStart];
426 $startTag = (
$row == $theadStart) ? (
' <thead>' .
PHP_EOL) :
'';
428 $startTag = (
$row == $tbodyStart) ? (
' <tbody>' .
PHP_EOL) :
'';
430 $endTag = (
$row == $theadEnd) ? (
' </thead>' .
PHP_EOL) :
'';
431 $cellType = (
$row >= $tbodyStart) ?
'td' :
'th';
433 return [$cellType, $startTag, $endTag];
450 foreach ($sheets as $sheet) {
455 [$min, $max] = explode(
':', $sheet->calculateWorksheetDataDimension());
463 while (
$row++ < $maxRow) {
464 [$cellType, $startTag, $endTag] = $this->
generateSheetTags(
$row, $theadStart, $theadEnd, $tbodyStart);
468 if (!isset($this->isSpannedRow[$sheet->getParent()->getIndex($sheet)][
$row])) {
473 while ($column <= $maxCol) {
475 if ($sheet->cellExistsByColumnAndRow($column,
$row)) {
478 $rowData[$column] =
'';
492 if ($this->isPdf && $this->useInlineCss) {
493 if ($this->sheetIndex ===
null && $sheetId + 1 < $this->spreadsheet->getSheetCount()) {
494 $html .=
'<div style="page-break-before:always" ></div>';
514 if ($this->sheetIndex ===
null) {
515 $sheets = $this->spreadsheet->getAllSheets();
517 $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
524 if (count($sheets) > 1) {
530 foreach ($sheets as $sheet) {
531 $html .=
' <li class="sheet' . $sheetId .
'"><a href="#sheet' . $sheetId .
'">' . $sheet->getTitle() .
'</a></li>' .
PHP_EOL;
561 if ($this->includeCharts) {
562 foreach ($pSheet->getChartCollection() as $chart) {
563 if ($chart instanceof
Chart) {
565 $chartCoordinates = $chart->getTopLeftPosition();
568 if ($chartTL[1] > $rowMax) {
569 $rowMax = $chartTL[1];
571 $colMax = $chartTL[0];
578 return [$rowMax, $colMax, $anyfound];
585 foreach ($pSheet->getDrawingCollection() as $drawing) {
589 if ($imageTL[1] > $rowMax) {
590 $rowMax = $imageTL[1];
592 $colMax = $imageTL[0];
598 if (
$row === $rowMax || !$anyfound) {
605 while (
$row <= $rowMax) {
607 for ($col =
'A'; $col != $colMax; ++$col) {
611 $html .=
"<td class='style0' style='position: relative;'>$htmlx</td>";
613 $html .=
"<td class='style0'></td>";
654 foreach ($pSheet->getDrawingCollection() as $drawing) {
655 if ($drawing->getCoordinates() != $coordinates) {
658 $filedesc = $drawing->getDescription();
659 $filedesc = $filedesc ? htmlspecialchars($filedesc, ENT_QUOTES) :
'Embedded image';
660 if ($drawing instanceof
Drawing) {
678 if ($this->embedImages && !$this->isPdf) {
679 $picture = @file_get_contents(
$filename);
680 if ($picture !==
false) {
683 $base64 = base64_encode($picture);
684 $imageData =
'data:' . $imageDetails[
'mime'] .
';base64,' . $base64;
688 $html .=
'<img style="position: absolute; z-index: 1; left: ' .
689 $drawing->getOffsetX() .
'px; top: ' . $drawing->getOffsetY() .
'px; width: ' .
690 $drawing->getWidth() .
'px; height: ' . $drawing->getHeight() .
'px;" src="' .
691 $imageData .
'" alt="' . $filedesc .
'" />';
693 $imageResource = $drawing->getImageResource();
694 if ($imageResource) {
696 imagepng($imageResource);
697 $contents = ob_get_contents();
700 $dataUri =
'data:image/jpeg;base64,' . base64_encode($contents);
706 $html .=
'<img alt="' . $filedesc .
'" src="' . $dataUri .
'" style="max-width:100%;width:' . $drawing->getWidth() .
'px;" />';
735 foreach ($pSheet->getChartCollection() as $chart) {
736 if ($chart instanceof
Chart) {
737 $chartCoordinates = $chart->getTopLeftPosition();
738 if ($chartCoordinates[
'cell'] == $coordinates) {
740 if (!$chart->render($chartFileName)) {
745 $imageDetails = getimagesize($chartFileName);
746 $filedesc = $chart->getTitle();
748 $filedesc = $filedesc ? htmlspecialchars($filedesc, ENT_QUOTES) :
'Embedded chart';
749 if ($fp = fopen($chartFileName,
'rb', 0)) {
750 $picture = fread($fp, filesize($chartFileName));
753 $base64 = base64_encode($picture);
754 $imageData =
'data:' . $imageDetails[
'mime'] .
';base64,' . $base64;
756 $html .=
'<img style="position: absolute; z-index: 1; left: ' . $chartCoordinates[
'xOffset'] .
'px; top: ' . $chartCoordinates[
'yOffset'] .
'px; width: ' . $imageDetails[0] .
'px; height: ' . $imageDetails[1] .
'px;" src="' . $imageData .
'" alt="' . $filedesc .
'" />' .
PHP_EOL;
758 unlink($chartFileName);
786 return is_array($cap) ? implode(
' ', $cap) : $cap;
799 $css = $this->
buildCSS($generateSurroundingHTML);
805 if ($generateSurroundingHTML) {
807 $html .= (array_key_exists(
'html', $css)) ? (
' html { ' . $this->
assembleCSS($css[
'html']) .
' }' .
PHP_EOL) :
'';
811 foreach ($css as $styleName => $styleDefinition) {
812 if ($styleName !=
'html') {
819 if ($generateSurroundingHTML) {
830 foreach ($sheet->getRowDimensions() as $rowDimension) {
831 $row = $rowDimension->getRowIndex() - 1;
836 if ($rowDimension->getRowHeight() != -1) {
837 $pt_height = $rowDimension->getRowHeight();
838 $css[
'table.sheet' .
$sheetIndex .
' tr.row' .
$row][
'height'] = $pt_height .
'pt';
840 if ($rowDimension->getVisible() ===
false) {
841 $css[
'table.sheet' .
$sheetIndex .
' tr.row' .
$row][
'display'] =
'none';
842 $css[
'table.sheet' .
$sheetIndex .
' tr.row' .
$row][
'visibility'] =
'hidden';
850 $sheetIndex = $sheet->getParent()->getIndex($sheet);
854 $sheet->calculateColumnWidths();
859 while ($column++ < $highestColumnIndex) {
861 $css[
'table.sheet' .
$sheetIndex .
' col.col' . $column][
'width'] =
'42pt';
865 foreach ($sheet->getColumnDimensions() as $columnDimension) {
867 $width = SharedDrawing::cellDimensionToPixels($columnDimension->getWidth(), $this->defaultFont);
868 $width = SharedDrawing::pixelsToPoints($width);
869 if ($columnDimension->getVisible() ===
false) {
870 $css[
'table.sheet' .
$sheetIndex .
' .column' . $column][
'display'] =
'none';
873 $this->columnWidths[
$sheetIndex][$column] = $width;
874 $css[
'table.sheet' .
$sheetIndex .
' col.col' . $column][
'width'] = $width .
'pt';
879 $rowDimension = $sheet->getDefaultRowDimension();
884 if ($rowDimension->getRowHeight() == -1) {
885 $pt_height = SharedFont::getDefaultRowHeightByFont($this->spreadsheet->getDefaultStyle()->getFont());
887 $pt_height = $rowDimension->getRowHeight();
889 $css[
'table.sheet' .
$sheetIndex .
' tr'][
'height'] = $pt_height .
'pt';
890 if ($rowDimension->getVisible() ===
false) {
891 $css[
'table.sheet' .
$sheetIndex .
' tr'][
'display'] =
'none';
892 $css[
'table.sheet' .
$sheetIndex .
' tr'][
'visibility'] =
'hidden';
905 public function buildCSS($generateSurroundingHTML =
true)
908 if ($this->cssStyles !==
null) {
919 if ($generateSurroundingHTML) {
921 $css[
'html'][
'font-family'] =
'Calibri, Arial, Helvetica, sans-serif';
922 $css[
'html'][
'font-size'] =
'11pt';
923 $css[
'html'][
'background-color'] =
'white';
927 $css[
'a.comment-indicator:hover + div.comment'] = [
928 'background' =>
'#ffd',
929 'position' =>
'absolute',
930 'display' =>
'block',
931 'border' =>
'1px solid black',
932 'padding' =>
'0.5em',
935 $css[
'a.comment-indicator'] = [
936 'background' =>
'red',
937 'display' =>
'inline-block',
938 'border' =>
'1px solid black',
943 $css[
'div.comment'][
'display'] =
'none';
946 $css[
'table'][
'border-collapse'] =
'collapse';
949 $css[
'.b'][
'text-align'] =
'center';
952 $css[
'.e'][
'text-align'] =
'center';
955 $css[
'.f'][
'text-align'] =
'right';
958 $css[
'.inlineStr'][
'text-align'] =
'left';
961 $css[
'.n'][
'text-align'] =
'right';
964 $css[
'.s'][
'text-align'] =
'left';
967 foreach ($this->spreadsheet->getCellXfCollection() as
$index =>
$style) {
974 if ($this->sheetIndex ===
null) {
975 $sheets = $this->spreadsheet->getAllSheets();
977 $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
981 foreach ($sheets as $sheet) {
986 if ($this->cssStyles ===
null) {
987 $this->cssStyles = $css;
1004 $this->createCSSStyleBorders($pStyle->
getBorders()),
1005 $this->createCSSStyleFont($pStyle->
getFont()),
1006 $this->createCSSStyleFill($pStyle->
getFill())
1026 $css[
'text-align'] = $textAlign;
1027 if (in_array($textAlign, [
'left',
'right'])) {
1028 $css[
'padding-' . $textAlign] = (string) ((
int) $pStyle->
getIndent() * 9) .
'px';
1047 $css[
'font-weight'] =
'bold';
1050 $css[
'text-decoration'] =
'underline line-through';
1052 $css[
'text-decoration'] =
'underline';
1054 $css[
'text-decoration'] =
'line-through';
1057 $css[
'font-style'] =
'italic';
1060 $css[
'color'] =
'#' . $pStyle->
getColor()->getRGB();
1061 $css[
'font-family'] =
'\'' . $pStyle->
getName() .
'\'';
1062 $css[
'font-size'] = $pStyle->
getSize() .
'pt';
1100 return $borderStyle .
' #' . $pStyle->
getColor()->getRGB() . (($borderStyle ==
'none') ?
'' :
' !important');
1118 $css[
'background-color'] = $value;
1138 $style = isset($this->cssStyles[
'table']) ?
1139 $this->
assembleCSS($this->cssStyles[
'table']) :
'';
1141 $prntgrid = $pSheet->getPrintGridlines();
1142 $viewgrid = $this->isPdf ? $prntgrid : $pSheet->getShowGridlines();
1143 if ($viewgrid && $prntgrid) {
1144 $html =
" <table border='1' cellpadding='1' $id cellspacing='1' style='$style' class='gridlines gridlinesp'>" .
PHP_EOL;
1145 } elseif ($viewgrid) {
1146 $html =
" <table border='0' cellpadding='0' $id cellspacing='0' style='$style' class='gridlines'>" .
PHP_EOL;
1147 } elseif ($prntgrid) {
1148 $html =
" <table border='0' cellpadding='0' $id cellspacing='0' style='$style' class='gridlinesp'>" .
PHP_EOL;
1150 $html =
" <table border='0' cellpadding='1' $id cellspacing='0' style='$style'>" .
PHP_EOL;
1158 if (!$this->useInlineCss) {
1159 $gridlines = $pSheet->getShowGridlines() ?
' gridlines' :
'';
1160 $gridlinesp = $pSheet->getPrintGridlines() ?
' gridlinesp' :
'';
1161 $html .=
" <table border='0' cellpadding='0' cellspacing='0' $id class='sheet$sheetIndex$gridlines$gridlinesp'>" .
PHP_EOL;
1177 $sheetIndex = $pSheet->getParent()->getIndex($pSheet);
1181 $id = $showid ?
"id='sheet$sheetIndex'" :
'';
1183 $html .=
"<div style='page: page$sheetIndex'>\n";
1185 $html .=
"<div style='page: page$sheetIndex' class='scrpgbrk'>\n";
1193 while (
$i++ < $highestColumnIndex) {
1194 if (!$this->useInlineCss) {
1226 if (count($pSheet->getBreaks()) > 0) {
1227 $breaks = $pSheet->getBreaks();
1230 if (isset($breaks[
'A' . $pRow])) {
1233 if ($this->isPdf && $this->useInlineCss) {
1234 $html .=
'<div style="page-break-before:always" />';
1244 if (!$this->useInlineCss) {
1247 $style = isset($this->cssStyles[
'table.sheet' .
$sheetIndex .
' tr.row' . $pRow])
1258 $cell = ($cellAddress >
'') ? $pSheet->getCell($cellAddress) :
'';
1260 if (!$this->useInlineCss) {
1261 $cssClass =
'column' . $colNum;
1279 return [$cell, $cssClass, $coordinate];
1285 $elements = $cell->getValue()->getRichTextElements();
1286 foreach ($elements as $element) {
1288 if ($element instanceof
Run) {
1292 if ($element->getFont()->getSuperscript()) {
1293 $cellData .=
'<sup>';
1294 $cellEnd =
'</sup>';
1295 } elseif ($element->getFont()->getSubscript()) {
1296 $cellData .=
'<sub>';
1297 $cellEnd =
'</sub>';
1301 $cellText = $element->getText();
1302 $cellData .= htmlspecialchars($cellText);
1304 $cellData .= $cellEnd;
1306 $cellData .=
'</span>';
1309 $cellText = $element->getText();
1310 $cellData .= htmlspecialchars($cellText);
1317 if ($cell->getValue() instanceof
RichText) {
1320 $origData = $this->preCalculateFormulas ? $cell->getCalculatedValue() : $cell->getValue();
1323 $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(),
1324 [$this,
'formatColor']
1326 if ($cellData === $origData) {
1327 $cellData = htmlspecialchars($cellData ??
'');
1329 if ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperscript()) {
1330 $cellData =
'<sup>' . $cellData .
'</sup>';
1331 } elseif ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSubscript()) {
1332 $cellData =
'<sub>' . $cellData .
'</sub>';
1339 $cellData =
' ';
1340 if ($cell instanceof
Cell) {
1351 $cellData = preg_replace(
'/(?m)(?:^|\\G) /',
' ', $cellData);
1354 $cellData = nl2br($cellData);
1357 if (!$this->useInlineCss) {
1358 $cssClass .=
' style' . $cell->getXfIndex();
1359 $cssClass .=
' ' . $cell->getDataType();
1361 if ($cellType ==
'th') {
1362 if (isset($this->cssStyles[
'th.style' . $cell->getXfIndex()])) {
1363 $cssClass = array_merge($cssClass, $this->cssStyles[
'th.style' . $cell->getXfIndex()]);
1366 if (isset($this->cssStyles[
'td.style' . $cell->getXfIndex()])) {
1367 $cssClass = array_merge($cssClass, $this->cssStyles[
'td.style' . $cell->getXfIndex()]);
1372 $sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex());
1375 && isset($this->cssStyles[
'.' . $cell->getDataType()][
'text-align'])
1377 $cssClass[
'text-align'] = $this->cssStyles[
'.' . $cell->getDataType()][
'text-align'];
1382 if (is_string($cssClass)) {
1383 $cssClass .=
' style0';
1392 return $this->includeCharts ? $this->
writeChartInCell($pSheet, $coordinate) :
'';
1397 $html .= ($colSpan > 1) ? (
' colspan="' . $colSpan .
'"') :
'';
1398 $html .= ($rowSpan > 1) ? (
' rowspan="' . $rowSpan .
'"') :
'';
1403 private function generateRowWriteCell(&
$html, $pSheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum,
$sheetIndex, $pRow): void
1410 $html .=
' <' . $cellType;
1411 if (!$this->useInlineCss && !$this->isPdf) {
1412 $html .=
' class="' . $cssClass .
'"';
1414 $html .=
" style='position: relative;'";
1420 if ($this->useInlineCss) {
1421 $xcssClass = $cssClass;
1423 $html .=
' class="' . $cssClass .
'"';
1428 $e = $colNum + $colSpan - 1;
1434 $xcssClass[
'width'] = $width .
'pt';
1438 if (isset($this->cssStyles[
'table.sheet' .
$sheetIndex .
' tr.row' . $pRow][
'height'])) {
1439 $height = $this->cssStyles[
'table.sheet' .
$sheetIndex .
' tr.row' . $pRow][
'height'];
1440 $xcssClass[
'height'] = $height;
1445 $xcssClass[
'position'] =
'relative';
1476 $sheetIndex = $pSheet->getParent()->getIndex($pSheet);
1481 foreach ($pValues as $cellAddress) {
1482 [$cell, $cssClass, $coordinate] = $this->
generateRowCellCss($pSheet, $cellAddress, $pRow, $colNum);
1491 if ($pSheet->hyperlinkExists($coordinate) && !$pSheet->getHyperlink($coordinate)->isInternal()) {
1492 $cellData =
'<a href="' . htmlspecialchars($pSheet->getHyperlink($coordinate)->getUrl()) .
'" title="' . htmlspecialchars($pSheet->getHyperlink($coordinate)->getTooltip()) .
'">' . $cellData .
'</a>';
1496 $writeCell = !(isset($this->isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])
1497 && $this->isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]);
1502 if (isset($this->isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])) {
1503 $spans = $this->isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum];
1504 $rowSpan = $spans[
'rowspan'];
1505 $colSpan = $spans[
'colspan'];
1510 if (!$this->useInlineCss) {
1511 $cssClass .=
' style' . $pSheet->getCell($endCellCoord)->getXfIndex();
1517 $this->
generateRowWriteCell(
$html, $pSheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum,
$sheetIndex, $pRow);
1539 foreach ($pValue as $property => $value) {
1540 $pairs[] = $property .
':' . $value;
1542 $string = implode(
'; ', $pairs);
1566 $this->imagesRoot = $pValue;
1590 $this->embedImages = $pValue;
1614 $this->useInlineCss = $pValue;
1646 $this->useEmbeddedCSS = $pValue;
1665 $color_regex =
'/^\\[[a-zA-Z]+\\]/';
1666 if (preg_match($color_regex, $pFormat, $matches)) {
1667 $color = str_replace([
'[',
']'],
'', $matches[0]);
1668 $color = strtolower($color);
1672 $value = htmlspecialchars($pValue);
1675 if ($color !==
null) {
1676 $value =
'<span style="color:' . $color .
'">' . $value .
'</span>';
1687 if ($this->spansAreCalculated) {
1693 $sheetIndexes = $this->sheetIndex !==
null ?
1697 $sheet = $this->spreadsheet->getSheet(
$sheetIndex);
1699 $candidateSpannedRow = [];
1702 foreach ($sheet->getMergeCells() as $cells) {
1715 while (
$r++ <
$lr) {
1717 $candidateSpannedRow[
$r] =
$r;
1720 while (
$c++ <
$lc) {
1721 if (!(
$c == $fc &&
$r == $fr)) {
1724 'baseCell' => [$fr, $fc],
1729 'xlrowspan' =>
$lr - $fr + 1,
1730 'rowspan' =>
$lr - $fr + 1,
1731 'xlcolspan' =>
$lc - $fc + 1,
1732 'colspan' =>
$lc - $fc + 1,
1745 $this->spansAreCalculated =
true;
1753 foreach ($candidateSpannedRow as $rowIndex) {
1754 if (isset($this->isSpannedCell[
$sheetIndex][$rowIndex])) {
1755 if (count($this->isSpannedCell[
$sheetIndex][$rowIndex]) == $countColumns) {
1756 $this->isSpannedRow[
$sheetIndex][$rowIndex] = $rowIndex;
1763 foreach ($this->isSpannedRow[
$sheetIndex] as $rowIndex) {
1764 $adjustedBaseCells = [];
1766 $e = $countColumns - 1;
1768 $baseCell = $this->isSpannedCell[
$sheetIndex][$rowIndex][
$c][
'baseCell'];
1770 if (!in_array($baseCell, $adjustedBaseCells)) {
1772 --$this->isBaseCell[
$sheetIndex][$baseCell[0]][$baseCell[1]][
'rowspan'];
1773 $adjustedBaseCells[] = $baseCell;
1792 if (!$this->isPdf && isset($pSheet->getComments()[$coordinate])) {
1794 $sanitizedString =
$sanitizer->purify($pSheet->getComment($coordinate)->getText()->getPlainText());
1795 if ($sanitizedString !==
'') {
1796 $result .=
'<a class="comment-indicator"></a>';
1797 $result .=
'<div class="comment">' . nl2br($sanitizedString) .
'</div>';
1819 if ($this->sheetIndex ===
null) {
1820 $sheets = $this->spreadsheet->getAllSheets();
1822 $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
1826 $htmlPage = $generateSurroundingHTML ? (
'<style type="text/css">' .
PHP_EOL) :
'';
1830 foreach ($sheets as $pSheet) {
1831 $htmlPage .=
"@page page$sheetId { ";
1833 $htmlPage .=
'margin-left: ' . $left;
1834 $right = StringHelper::FormatNumber($pSheet->getPageMargins()->getRight()) .
'in; ';
1835 $htmlPage .=
'margin-right: ' . $right;
1836 $top = StringHelper::FormatNumber($pSheet->getPageMargins()->getTop()) .
'in; ';
1837 $htmlPage .=
'margin-top: ' . $top;
1838 $bottom = StringHelper::FormatNumber($pSheet->getPageMargins()->getBottom()) .
'in; ';
1839 $htmlPage .=
'margin-bottom: ' . $bottom;
1840 $orientation = $pSheet->getPageSetup()->getOrientation();
1842 $htmlPage .=
'size: landscape; ';
1844 $htmlPage .=
'size: portrait; ';
1850.navigation {page-
break-after: always;}
1851.scrpgbrk, div + div {page-
break-before: always;}
1853 .gridlines td {border: 1px solid black;}
1854 .gridlines th {border: 1px solid black;}
1855 body>div {margin-top: 5px;}
1856 body>div:first-child {margin-top: 0;}
1857 .scrpgbrk {margin-top: 1px;}
1860 .gridlinesp td {border: 1px solid black;}
1861 .gridlinesp th {border: 1px solid black;}
1862 .navigation {display: none;}
1866 $htmlPage .= $generateSurroundingHTML ? (
'</style>' .
PHP_EOL) :
'';
HTMLPurifier($html, $config=null)
Purify HTML.
const EOF
How fgetc() reports an End Of File.
An exception for terminatinating execution or to throw for unit testing.
const RETURN_ARRAY_AS_VALUE
static setArrayReturnType($returnType)
Set the Array Return Type (Array or Value of first element in the array).
static getArrayReturnType()
Return the Array Return Type (Array or Value of first element in the array).
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
Helper class to manipulate cell coordinates.
static coordinateFromString($pCoordinateString)
Coordinate from string.
static indexesFromString(string $coordinates)
Get indexes from a string coordinates.
static columnIndexFromString($pString)
Column index from string.
static stringFromColumnIndex($columnIndex)
String from column index.
static splitRange($pRange)
Split range into coordinate strings.
static sysGetTempDir()
Get the systems temporary directory.
static formatNumber($value)
Formats a numeric value as a string for output in various output writers forcing point as decimal sep...
const HORIZONTAL_CENTER_CONTINUOUS
getHorizontal()
Get Horizontal.
getVertical()
Get Vertical.
getColor()
Get Border Color.
const BORDER_MEDIUMDASHDOT
getBorderStyle()
Get Border style.
const BORDER_MEDIUMDASHDOTDOT
const BORDER_SLANTDASHDOT
getFillType()
Get Fill Type.
getStartColor()
Get Start Color.
getStrikethrough()
Get Strikethrough.
getUnderline()
Get Underline.
getAlignment()
Get Alignment.
const ORIENTATION_LANDSCAPE
const ORIENTATION_PORTRAIT
openFileHandle($filename)
Open file handle.
maybeCloseFileHandle()
Close file handle only if we opened it ourselves.
generateRowStart(Worksheet $pSheet, $sheetIndex, $pRow)
Generate row start.
setImagesRoot($pValue)
Set images root.
createCSSStyleFill(Fill $pStyle)
Create CSS style (Fill).
generateRow(Worksheet $pSheet, array $pValues, $pRow, $cellType)
Generate row.
setEditHtmlCallback(?callable $callback)
Set a callback to edit the entire HTML.
calculateSpansOmitRows($sheet, $sheetIndex, $candidateSpannedRow)
generateRowCellCss($pSheet, $cellAddress, $pRow, $colNum)
setEmbedImages($pValue)
Set embed images.
mapVAlign($vAlign)
Map VAlign.
generateRowSpans($html, $rowSpan, $colSpan)
writeAllSheets()
Write all sheets (resets sheetIndex to NULL).
generateRowCellDataValue($pSheet, $cell, &$cellData)
generateSheetTags($row, $theadStart, $theadEnd, $tbodyStart)
generateRowCellDataValueRich($cell, &$cellData)
generateSheetData()
Generate sheet data.
calculateSpans()
Calculate information about HTML colspan and rowspan which is not always the same as Excel's.
generateStyles($generateSurroundingHTML=true)
Generate CSS styles.
getImagesRoot()
Get images root.
static getChartCaption($cap)
Extend Row if chart is placed after nominal end of row.
generateRowWriteCell(&$html, $pSheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $pRow)
createCSSStyleFont(Font $pStyle)
Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Font).
generateHtmlAll()
Save Spreadsheet as html to variable.
generateHTMLFooter()
Generate HTML footer.
generatePageDeclarations($generateSurroundingHTML)
generateTableFooter()
Generate table footer.
createCSSStyle(Style $pStyle)
Create CSS style.
extendRowsForChartsAndImages(Worksheet $pSheet, int $row)
generateTableHeader($pSheet, $showid=true)
Generate table header.
createCSSStyleBorders(Borders $pStyle)
Create CSS style (Borders).
buildCssPerSheet(Worksheet $sheet, array &$css)
setSheetIndex($pValue)
Set sheet index.
generateHTMLHeader($pIncludeStyles=false)
Generate HTML header.
createCSSStyleBorder(Border $pStyle)
Create CSS style (Border).
assembleCSS(array $pValue=[])
Takes array where of CSS properties / values and converts to CSS string.
generateRowIncludeCharts($pSheet, $coordinate)
getEmbedImages()
Get embed images.
generateTableTag($pSheet, $id, &$html, $sheetIndex)
generateRowCellData($pSheet, $cell, &$cssClass, $cellType)
static winFileToUrl($filename)
Convert Windows file name to file protocol URL.
generateTableTagInline($pSheet, $id)
setUseInlineCss($pValue)
Set use inline CSS?
static generateMeta($val, $desc)
getGenerateSheetNavigationBlock()
Get sheet index.
buildCSS($generateSurroundingHTML=true)
Build CSS styles.
getSheetIndex()
Get sheet index.
generateNavigation()
Generate sheet tabs.
writeImageInCell(Worksheet $pSheet, $coordinates)
Generate image tag in cell.
$generateSheetNavigationBlock
buildCssRowHeights(Worksheet $sheet, array &$css, int $sheetIndex)
setGenerateSheetNavigationBlock($pValue)
Set sheet index.
setUseEmbeddedCSS($pValue)
Set use embedded CSS?
writeChartInCell(Worksheet $pSheet, $coordinates)
Generate chart tag in cell.
formatColor($pValue, $pFormat)
Add color to formatted string as inline style.
mapHAlign($hAlign)
Map HAlign.
save($pFilename)
Save Spreadsheet to file.
mapBorderStyle($borderStyle)
Map border style.
createCSSStyleAlignment(Alignment $pStyle)
Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Alignment).
getUseEmbeddedCSS()
Get use embedded CSS?
getUseInlineCss()
Get use inline CSS?
__construct(Spreadsheet $spreadsheet)
Create a new HTML.
writeComment(Worksheet $pSheet, $coordinate)
Write a comment in the same format as LibreOffice.
extendRowsForCharts(Worksheet $pSheet, int $row)
Extend Row if chart is placed after nominal end of row.
generateSheetStarts($sheet, $rowMin)
if(!array_key_exists('StateId', $_REQUEST)) $id
if(empty( $files_to_scan)) $sanitizer