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

Public Member Functions

 __construct (PHPExcel $phpExcel)
 Create a new PHPExcel_Writer_HTML. More...
 
 save ($pFilename=null)
 Save PHPExcel to file. More...
 
 getSheetIndex ()
 Get sheet index. More...
 
 setSheetIndex ($pValue=0)
 Set sheet index. More...
 
 getGenerateSheetNavigationBlock ()
 Get sheet index. More...
 
 setGenerateSheetNavigationBlock ($pValue=true)
 Set sheet index. More...
 
 writeAllSheets ()
 Write all sheets (resets sheetIndex to NULL) More...
 
 generateHTMLHeader ($pIncludeStyles=false)
 Generate HTML header. More...
 
 generateSheetData ()
 Generate sheet data. More...
 
 generateNavigation ()
 Generate sheet tabs. More...
 
 generateStyles ($generateSurroundingHTML=true)
 Generate CSS styles. More...
 
 buildCSS ($generateSurroundingHTML=true)
 Build CSS styles. More...
 
 generateHTMLFooter ()
 Generate HTML footer. More...
 
 getImagesRoot ()
 Get images root. More...
 
 setImagesRoot ($pValue='.')
 Set images root. More...
 
 getEmbedImages ()
 Get embed images. More...
 
 setEmbedImages ($pValue='.')
 Set embed images. More...
 
 getUseInlineCss ()
 Get use inline CSS? More...
 
 setUseInlineCss ($pValue=false)
 Set use inline CSS? More...
 
 formatColor ($pValue, $pFormat)
 Add color to formatted string as inline style. More...
 
- Public Member Functions inherited from PHPExcel_Writer_Abstract
 getIncludeCharts ()
 Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PHPExcel object. More...
 
 setIncludeCharts ($pValue=FALSE)
 Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PHPExcel object. More...
 
 getPreCalculateFormulas ()
 Get Pre-Calculate Formulas flag If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file If false, then formulae are not calculated on save. More...
 
 setPreCalculateFormulas ($pValue=TRUE)
 Set Pre-Calculate Formulas Set to true (the default) to advise the Writer to calculate all formulae on save Set to false to prevent precalculation of formulae on save. More...
 
 getUseDiskCaching ()
 Get use disk caching where possible? More...
 
 setUseDiskCaching ($pValue=FALSE, $pDirectory=NULL)
 Set use disk caching where possible? More...
 
 getDiskCachingDirectory ()
 Get disk caching directory. More...
 
 save ($pFilename=NULL)
 Save PHPExcel to file. More...
 

Protected Attributes

 $_phpExcel
 
 $_isPdf = false
 
- Protected Attributes inherited from PHPExcel_Writer_Abstract
 $_includeCharts = FALSE
 
 $_preCalculateFormulas = TRUE
 
 $_useDiskCaching = FALSE
 
 $_diskCachingDirectory = './'
 

Private Member Functions

 _mapVAlign ($vAlign)
 Map VAlign. More...
 
 _mapHAlign ($hAlign)
 Map HAlign. More...
 
 _mapBorderStyle ($borderStyle)
 Map border style. More...
 
 _extendRowsForChartsAndImages (PHPExcel_Worksheet $pSheet, $row)
 
 _writeImageInCell (PHPExcel_Worksheet $pSheet, $coordinates)
 Generate image tag in cell. More...
 
 _writeChartInCell (PHPExcel_Worksheet $pSheet, $coordinates)
 Generate chart tag in cell. More...
 
 _createCSSStyle (PHPExcel_Style $pStyle)
 Create CSS style. More...
 
 _createCSSStyleAlignment (PHPExcel_Style_Alignment $pStyle)
 Create CSS style (PHPExcel_Style_Alignment) More...
 
 _createCSSStyleFont (PHPExcel_Style_Font $pStyle)
 Create CSS style (PHPExcel_Style_Font) More...
 
 _createCSSStyleBorders (PHPExcel_Style_Borders $pStyle)
 Create CSS style (PHPExcel_Style_Borders) More...
 
 _createCSSStyleBorder (PHPExcel_Style_Border $pStyle)
 Create CSS style (PHPExcel_Style_Border) More...
 
 _createCSSStyleFill (PHPExcel_Style_Fill $pStyle)
 Create CSS style (PHPExcel_Style_Fill) More...
 
 _generateTableHeader ($pSheet)
 Generate table header. More...
 
 _generateTableFooter ()
 Generate table footer. More...
 
 _generateRow (PHPExcel_Worksheet $pSheet, $pValues=null, $pRow=0, $cellType='td')
 Generate row. More...
 
 _assembleCSS ($pValue=array())
 Takes array where of CSS properties / values and converts to CSS string. More...
 
 _calculateSpans ()
 Calculate information about HTML colspan and rowspan which is not always the same as Excel's. More...
 
 _setMargins (PHPExcel_Worksheet $pSheet)
 

Private Attributes

 $_sheetIndex = 0
 
 $_imagesRoot = '.'
 
 $_embedImages = FALSE
 
 $_useInlineCss = false
 
 $_cssStyles = null
 
 $_columnWidths = null
 
 $_defaultFont
 
 $_spansAreCalculated = false
 
 $_isSpannedCell = array()
 
 $_isBaseCell = array()
 
 $_isSpannedRow = array()
 
 $_generateSheetNavigationBlock = true
 

Detailed Description

Definition at line 36 of file HTML.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_Writer_HTML::__construct ( PHPExcel  $phpExcel)

Create a new PHPExcel_Writer_HTML.

Parameters
PHPExcel$phpExcelPHPExcel object

Reimplemented in PHPExcel_Writer_PDF_Core, PHPExcel_Writer_PDF_DomPDF, PHPExcel_Writer_PDF_mPDF, and PHPExcel_Writer_PDF_tcPDF.

Definition at line 140 of file HTML.php.

140 {
141 $this->_phpExcel = $phpExcel;
142 $this->_defaultFont = $this->_phpExcel->getDefaultStyle()->getFont();
143 }
getDefaultStyle()
Get default style.
Definition: PHPExcel.php:925

References PHPExcel\getDefaultStyle().

+ Here is the call graph for this function:

Member Function Documentation

◆ _assembleCSS()

PHPExcel_Writer_HTML::_assembleCSS (   $pValue = array())
private

Takes array where of CSS properties / values and converts to CSS string.

Parameters
array
Returns
string

Definition at line 1333 of file HTML.php.

1334 {
1335 $pairs = array();
1336 foreach ($pValue as $property => $value) {
1337 $pairs[] = $property . ':' . $value;
1338 }
1339 $string = implode('; ', $pairs);
1340
1341 return $string;
1342 }

Referenced by _generateRow(), _generateTableHeader(), and generateStyles().

+ Here is the caller graph for this function:

◆ _calculateSpans()

PHPExcel_Writer_HTML::_calculateSpans ( )
private

Calculate information about HTML colspan and rowspan which is not always the same as Excel's.

Definition at line 1438 of file HTML.php.

1439 {
1440 // Identify all cells that should be omitted in HTML due to cell merge.
1441 // In HTML only the upper-left cell should be written and it should have
1442 // appropriate rowspan / colspan attribute
1443 $sheetIndexes = $this->_sheetIndex !== null ?
1444 array($this->_sheetIndex) : range(0, $this->_phpExcel->getSheetCount() - 1);
1445
1446 foreach ($sheetIndexes as $sheetIndex) {
1447 $sheet = $this->_phpExcel->getSheet($sheetIndex);
1448
1449 $candidateSpannedRow = array();
1450
1451 // loop through all Excel merged cells
1452 foreach ($sheet->getMergeCells() as $cells) {
1453 list($cells, ) = PHPExcel_Cell::splitRange($cells);
1454 $first = $cells[0];
1455 $last = $cells[1];
1456
1457 list($fc, $fr) = PHPExcel_Cell::coordinateFromString($first);
1459
1460 list($lc, $lr) = PHPExcel_Cell::coordinateFromString($last);
1462
1463 // loop through the individual cells in the individual merge
1464 $r = $fr - 1;
1465 while($r++ < $lr) {
1466 // also, flag this row as a HTML row that is candidate to be omitted
1467 $candidateSpannedRow[$r] = $r;
1468
1469 $c = $fc - 1;
1470 while($c++ < $lc) {
1471 if ( !($c == $fc && $r == $fr) ) {
1472 // not the upper-left cell (should not be written in HTML)
1473 $this->_isSpannedCell[$sheetIndex][$r][$c] = array(
1474 'baseCell' => array($fr, $fc),
1475 );
1476 } else {
1477 // upper-left is the base cell that should hold the colspan/rowspan attribute
1478 $this->_isBaseCell[$sheetIndex][$r][$c] = array(
1479 'xlrowspan' => $lr - $fr + 1, // Excel rowspan
1480 'rowspan' => $lr - $fr + 1, // HTML rowspan, value may change
1481 'xlcolspan' => $lc - $fc + 1, // Excel colspan
1482 'colspan' => $lc - $fc + 1, // HTML colspan, value may change
1483 );
1484 }
1485 }
1486 }
1487 }
1488
1489 // Identify which rows should be omitted in HTML. These are the rows where all the cells
1490 // participate in a merge and the where base cells are somewhere above.
1491 $countColumns = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn());
1492 foreach ($candidateSpannedRow as $rowIndex) {
1493 if (isset($this->_isSpannedCell[$sheetIndex][$rowIndex])) {
1494 if (count($this->_isSpannedCell[$sheetIndex][$rowIndex]) == $countColumns) {
1495 $this->_isSpannedRow[$sheetIndex][$rowIndex] = $rowIndex;
1496 };
1497 }
1498 }
1499
1500 // For each of the omitted rows we found above, the affected rowspans should be subtracted by 1
1501 if ( isset($this->_isSpannedRow[$sheetIndex]) ) {
1502 foreach ($this->_isSpannedRow[$sheetIndex] as $rowIndex) {
1503 $adjustedBaseCells = array();
1504 $c = -1;
1505 $e = $countColumns - 1;
1506 while($c++ < $e) {
1507 $baseCell = $this->_isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
1508
1509 if ( !in_array($baseCell, $adjustedBaseCells) ) {
1510 // subtract rowspan by 1
1511 --$this->_isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan'];
1512 $adjustedBaseCells[] = $baseCell;
1513 }
1514 }
1515 }
1516 }
1517
1518 // TODO: Same for columns
1519 }
1520
1521 // We have calculated the spans
1522 $this->_spansAreCalculated = true;
1523 }
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
Definition: Cell.php:580
static splitRange($pRange='A1:A1')
Split range into coordinate strings.
Definition: Cell.php:660
static columnIndexFromString($pString='A')
Column index from string.
Definition: Cell.php:782
$r
Definition: example_031.php:79

References $r, PHPExcel_Cell\columnIndexFromString(), PHPExcel_Cell\coordinateFromString(), and PHPExcel_Cell\splitRange().

Referenced by buildCSS(), and generateSheetData().

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

◆ _createCSSStyle()

PHPExcel_Writer_HTML::_createCSSStyle ( PHPExcel_Style  $pStyle)
private

Create CSS style.

Parameters
PHPExcel_Style$pStylePHPExcel_Style
Returns
array

Definition at line 874 of file HTML.php.

874 {
875 // Construct CSS
876 $css = '';
877
878 // Create CSS
879 $css = array_merge(
880 $this->_createCSSStyleAlignment($pStyle->getAlignment())
881 , $this->_createCSSStyleBorders($pStyle->getBorders())
882 , $this->_createCSSStyleFont($pStyle->getFont())
883 , $this->_createCSSStyleFill($pStyle->getFill())
884 );
885
886 // Return
887 return $css;
888 }
getBorders()
Get Borders.
Definition: Style.php:532
getFill()
Get Fill.
Definition: Style.php:500
getFont()
Get Font.
Definition: Style.php:510
getAlignment()
Get Alignment.
Definition: Style.php:542
_createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle)
Create CSS style (PHPExcel_Style_Alignment)
Definition: HTML.php:896

References _createCSSStyleAlignment(), PHPExcel_Style\getAlignment(), PHPExcel_Style\getBorders(), PHPExcel_Style\getFill(), and PHPExcel_Style\getFont().

Referenced by buildCSS().

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

◆ _createCSSStyleAlignment()

PHPExcel_Writer_HTML::_createCSSStyleAlignment ( PHPExcel_Style_Alignment  $pStyle)
private

Create CSS style (PHPExcel_Style_Alignment)

Parameters
PHPExcel_Style_Alignment$pStylePHPExcel_Style_Alignment
Returns
array

Definition at line 896 of file HTML.php.

896 {
897 // Construct CSS
898 $css = array();
899
900 // Create CSS
901 $css['vertical-align'] = $this->_mapVAlign($pStyle->getVertical());
902 if ($textAlign = $this->_mapHAlign($pStyle->getHorizontal())) {
903 $css['text-align'] = $textAlign;
904 if(in_array($textAlign,array('left','right')))
905 $css['padding-'.$textAlign] = (string)((int)$pStyle->getIndent() * 9).'px';
906 }
907
908 // Return
909 return $css;
910 }
getHorizontal()
Get Horizontal.
Definition: Alignment.php:210
getIndent()
Get indent.
Definition: Alignment.php:377
getVertical()
Get Vertical.
Definition: Alignment.php:243
_mapHAlign($hAlign)
Map HAlign.
Definition: HTML.php:212
_mapVAlign($vAlign)
Map VAlign.
Definition: HTML.php:196

References _mapHAlign(), _mapVAlign(), PHPExcel_Style_Alignment\getHorizontal(), PHPExcel_Style_Alignment\getIndent(), and PHPExcel_Style_Alignment\getVertical().

Referenced by _createCSSStyle().

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

◆ _createCSSStyleBorder()

PHPExcel_Writer_HTML::_createCSSStyleBorder ( PHPExcel_Style_Border  $pStyle)
private

Create CSS style (PHPExcel_Style_Border)

Parameters
PHPExcel_Style_Border$pStylePHPExcel_Style_Border
Returns
string

Definition at line 971 of file HTML.php.

971 {
972 // Create CSS
973// $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB();
974 // Create CSS - add !important to non-none border styles for merged cells
975 $borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle());
976 $css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important');
977
978 // Return
979 return $css;
980 }
getBorderStyle()
Get Border style.
Definition: Border.php:218
getColor()
Get Border Color.
Definition: Border.php:254
_mapBorderStyle($borderStyle)
Map border style.
Definition: HTML.php:230

References _mapBorderStyle(), PHPExcel_Style_Border\getBorderStyle(), and PHPExcel_Style_Border\getColor().

Referenced by _createCSSStyleBorders().

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

◆ _createCSSStyleBorders()

PHPExcel_Writer_HTML::_createCSSStyleBorders ( PHPExcel_Style_Borders  $pStyle)
private

Create CSS style (PHPExcel_Style_Borders)

Parameters
PHPExcel_Style_Borders$pStylePHPExcel_Style_Borders
Returns
array

Definition at line 951 of file HTML.php.

951 {
952 // Construct CSS
953 $css = array();
954
955 // Create CSS
956 $css['border-bottom'] = $this->_createCSSStyleBorder($pStyle->getBottom());
957 $css['border-top'] = $this->_createCSSStyleBorder($pStyle->getTop());
958 $css['border-left'] = $this->_createCSSStyleBorder($pStyle->getLeft());
959 $css['border-right'] = $this->_createCSSStyleBorder($pStyle->getRight());
960
961 // Return
962 return $css;
963 }
getLeft()
Get Left.
Definition: Borders.php:268
getBottom()
Get Bottom.
Definition: Borders.php:295
getRight()
Get Right.
Definition: Borders.php:277
_createCSSStyleBorder(PHPExcel_Style_Border $pStyle)
Create CSS style (PHPExcel_Style_Border)
Definition: HTML.php:971

References _createCSSStyleBorder(), PHPExcel_Style_Borders\getBottom(), PHPExcel_Style_Borders\getLeft(), PHPExcel_Style_Borders\getRight(), and PHPExcel_Style_Borders\getTop().

+ Here is the call graph for this function:

◆ _createCSSStyleFill()

PHPExcel_Writer_HTML::_createCSSStyleFill ( PHPExcel_Style_Fill  $pStyle)
private

Create CSS style (PHPExcel_Style_Fill)

Parameters
PHPExcel_Style_Fill$pStylePHPExcel_Style_Fill
Returns
array

Definition at line 988 of file HTML.php.

988 {
989 // Construct HTML
990 $css = array();
991
992 // Create CSS
993 $value = $pStyle->getFillType() == PHPExcel_Style_Fill::FILL_NONE ?
994 'white' : '#' . $pStyle->getStartColor()->getRGB();
995 $css['background-color'] = $value;
996
997 // Return
998 return $css;
999 }
getStartColor()
Get Start Color.
Definition: Fill.php:250
getFillType()
Get Fill Type.
Definition: Fill.php:194
const FILL_NONE
Definition: Fill.php:39

References PHPExcel_Style_Fill\FILL_NONE, PHPExcel_Style_Fill\getFillType(), and PHPExcel_Style_Fill\getStartColor().

+ Here is the call graph for this function:

◆ _createCSSStyleFont()

PHPExcel_Writer_HTML::_createCSSStyleFont ( PHPExcel_Style_Font  $pStyle)
private

Create CSS style (PHPExcel_Style_Font)

Parameters
PHPExcel_Style_Font$pStylePHPExcel_Style_Font
Returns
array

Definition at line 918 of file HTML.php.

918 {
919 // Construct CSS
920 $css = array();
921
922 // Create CSS
923 if ($pStyle->getBold()) {
924 $css['font-weight'] = 'bold';
925 }
926 if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE && $pStyle->getStrikethrough()) {
927 $css['text-decoration'] = 'underline line-through';
928 } else if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE) {
929 $css['text-decoration'] = 'underline';
930 } else if ($pStyle->getStrikethrough()) {
931 $css['text-decoration'] = 'line-through';
932 }
933 if ($pStyle->getItalic()) {
934 $css['font-style'] = 'italic';
935 }
936
937 $css['color'] = '#' . $pStyle->getColor()->getRGB();
938 $css['font-family'] = '\'' . $pStyle->getName() . '\'';
939 $css['font-size'] = $pStyle->getSize() . 'pt';
940
941 // Return
942 return $css;
943 }
getBold()
Get Bold.
Definition: Font.php:293
getSize()
Get Size.
Definition: Font.php:262
getUnderline()
Get Underline.
Definition: Font.php:419
getColor()
Get Color.
Definition: Font.php:485
getItalic()
Get Italic.
Definition: Font.php:324
getStrikethrough()
Get Strikethrough.
Definition: Font.php:454
getName()
Get Name.
Definition: Font.php:231
const UNDERLINE_NONE
Definition: Font.php:39

References PHPExcel_Style_Font\getBold(), PHPExcel_Style_Font\getColor(), PHPExcel_Style_Font\getItalic(), PHPExcel_Style_Font\getName(), PHPExcel_Style_Font\getSize(), PHPExcel_Style_Font\getStrikethrough(), PHPExcel_Style_Font\getUnderline(), and PHPExcel_Style_Font\UNDERLINE_NONE.

Referenced by _generateRow().

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

◆ _extendRowsForChartsAndImages()

PHPExcel_Writer_HTML::_extendRowsForChartsAndImages ( PHPExcel_Worksheet  $pSheet,
  $row 
)
private

Definition at line 511 of file HTML.php.

511 {
512 $rowMax = $row;
513 $colMax = 'A';
514 if ($this->_includeCharts) {
515 foreach ($pSheet->getChartCollection() as $chart) {
516 if ($chart instanceof PHPExcel_Chart) {
517 $chartCoordinates = $chart->getTopLeftPosition();
518 $chartTL = PHPExcel_Cell::coordinateFromString($chartCoordinates['cell']);
519 $chartCol = PHPExcel_Cell::columnIndexFromString($chartTL[0]);
520 if ($chartTL[1] > $rowMax) {
521 $rowMax = $chartTL[1];
522 if ($chartCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
523 $colMax = $chartTL[0];
524 }
525 }
526 }
527 }
528 }
529
530 foreach ($pSheet->getDrawingCollection() as $drawing) {
531 if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
532 $imageTL = PHPExcel_Cell::coordinateFromString($drawing->getCoordinates());
533 $imageCol = PHPExcel_Cell::columnIndexFromString($imageTL[0]);
534 if ($imageTL[1] > $rowMax) {
535 $rowMax = $imageTL[1];
536 if ($imageCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
537 $colMax = $imageTL[0];
538 }
539 }
540 }
541 }
542 $html = '';
543 $colMax++;
544 while ($row < $rowMax) {
545 $html .= '<tr>';
546 for ($col = 'A'; $col != $colMax; ++$col) {
547 $html .= '<td>';
548 $html .= $this->_writeImageInCell($pSheet, $col.$row);
549 if ($this->_includeCharts) {
550 $html .= $this->_writeChartInCell($pSheet, $col.$row);
551 }
552 $html .= '</td>';
553 }
554 ++$row;
555 $html .= '</tr>';
556 }
557 return $html;
558 }
getChartCollection()
Get collection of charts.
Definition: Worksheet.php:564
getDrawingCollection()
Get collection of drawings.
Definition: Worksheet.php:554
_writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates)
Generate chart tag in cell.
Definition: HTML.php:634
_writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates)
Generate image tag in cell.
Definition: HTML.php:569
$html
Definition: example_001.php:87

References $chart, $html, $row, _writeChartInCell(), _writeImageInCell(), PHPExcel_Cell\columnIndexFromString(), PHPExcel_Cell\coordinateFromString(), PHPExcel_Worksheet\getChartCollection(), and PHPExcel_Worksheet\getDrawingCollection().

Referenced by generateSheetData().

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

◆ _generateRow()

PHPExcel_Writer_HTML::_generateRow ( PHPExcel_Worksheet  $pSheet,
  $pValues = null,
  $pRow = 0,
  $cellType = 'td' 
)
private

Generate row.

Parameters
PHPExcel_Worksheet$pSheetPHPExcel_Worksheet
array$pValuesArray containing cells in a row
int$pRowRow number (0-based)
Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 1084 of file HTML.php.

1084 {
1085 if (is_array($pValues)) {
1086 // Construct HTML
1087 $html = '';
1088
1089 // Sheet index
1090 $sheetIndex = $pSheet->getParent()->getIndex($pSheet);
1091
1092 // DomPDF and breaks
1093 if ($this->_isPdf && count($pSheet->getBreaks()) > 0) {
1094 $breaks = $pSheet->getBreaks();
1095
1096 // check if a break is needed before this row
1097 if (isset($breaks['A' . $pRow])) {
1098 // close table: </table>
1099 $html .= $this->_generateTableFooter();
1100
1101 // insert page break
1102 $html .= '<div style="page-break-before:always" />';
1103
1104 // open table again: <table> + <col> etc.
1105 $html .= $this->_generateTableHeader($pSheet);
1106 }
1107 }
1108
1109 // Write row start
1110 if (!$this->_useInlineCss) {
1111 $html .= ' <tr class="row' . $pRow . '">' . PHP_EOL;
1112 } else {
1113 $style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow])
1114 ? $this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) : '';
1115
1116 $html .= ' <tr style="' . $style . '">' . PHP_EOL;
1117 }
1118
1119 // Write cells
1120 $colNum = 0;
1121 foreach ($pValues as $cellAddress) {
1122 $cell = ($cellAddress > '') ? $pSheet->getCell($cellAddress) : '';
1123 $coordinate = PHPExcel_Cell::stringFromColumnIndex($colNum) . ($pRow + 1);
1124 if (!$this->_useInlineCss) {
1125 $cssClass = '';
1126 $cssClass = 'column' . $colNum;
1127 } else {
1128 $cssClass = array();
1129 if ($cellType == 'th') {
1130 if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum])) {
1131 $this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum];
1132 }
1133 } else {
1134 if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) {
1135 $this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum];
1136 }
1137 }
1138 }
1139 $colSpan = 1;
1140 $rowSpan = 1;
1141
1142 // initialize
1143 $cellData = '&nbsp;';
1144
1145 // PHPExcel_Cell
1146 if ($cell instanceof PHPExcel_Cell) {
1147 $cellData = '';
1148 if (is_null($cell->getParent())) {
1149 $cell->attach($pSheet);
1150 }
1151 // Value
1152 if ($cell->getValue() instanceof PHPExcel_RichText) {
1153 // Loop through rich text elements
1154 $elements = $cell->getValue()->getRichTextElements();
1155 foreach ($elements as $element) {
1156 // Rich text start?
1157 if ($element instanceof PHPExcel_RichText_Run) {
1158 $cellData .= '<span style="' . $this->_assembleCSS($this->_createCSSStyleFont($element->getFont())) . '">';
1159
1160 if ($element->getFont()->getSuperScript()) {
1161 $cellData .= '<sup>';
1162 } else if ($element->getFont()->getSubScript()) {
1163 $cellData .= '<sub>';
1164 }
1165 }
1166
1167 // Convert UTF8 data to PCDATA
1168 $cellText = $element->getText();
1169 $cellData .= htmlspecialchars($cellText);
1170
1171 if ($element instanceof PHPExcel_RichText_Run) {
1172 if ($element->getFont()->getSuperScript()) {
1173 $cellData .= '</sup>';
1174 } else if ($element->getFont()->getSubScript()) {
1175 $cellData .= '</sub>';
1176 }
1177
1178 $cellData .= '</span>';
1179 }
1180 }
1181 } else {
1182 if ($this->_preCalculateFormulas) {
1184 $cell->getCalculatedValue(),
1185 $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(),
1186 array($this, 'formatColor')
1187 );
1188 } else {
1190 $cell->getValue(),
1191 $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(),
1192 array($this, 'formatColor')
1193 );
1194 }
1195 $cellData = htmlspecialchars($cellData);
1196 if ($pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getFont()->getSuperScript()) {
1197 $cellData = '<sup>'.$cellData.'</sup>';
1198 } elseif ($pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getFont()->getSubScript()) {
1199 $cellData = '<sub>'.$cellData.'</sub>';
1200 }
1201 }
1202
1203 // Converts the cell content so that spaces occuring at beginning of each new line are replaced by &nbsp;
1204 // Example: " Hello\n to the world" is converted to "&nbsp;&nbsp;Hello\n&nbsp;to the world"
1205 $cellData = preg_replace("/(?m)(?:^|\\G) /", '&nbsp;', $cellData);
1206
1207 // convert newline "\n" to '<br>'
1208 $cellData = nl2br($cellData);
1209
1210 // Extend CSS class?
1211 if (!$this->_useInlineCss) {
1212 $cssClass .= ' style' . $cell->getXfIndex();
1213 $cssClass .= ' ' . $cell->getDataType();
1214 } else {
1215 if ($cellType == 'th') {
1216 if (isset($this->_cssStyles['th.style' . $cell->getXfIndex()])) {
1217 $cssClass = array_merge($cssClass, $this->_cssStyles['th.style' . $cell->getXfIndex()]);
1218 }
1219 } else {
1220 if (isset($this->_cssStyles['td.style' . $cell->getXfIndex()])) {
1221 $cssClass = array_merge($cssClass, $this->_cssStyles['td.style' . $cell->getXfIndex()]);
1222 }
1223 }
1224
1225 // General horizontal alignment: Actual horizontal alignment depends on dataType
1226 $sharedStyle = $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() );
1227 if ($sharedStyle->getAlignment()->getHorizontal() == PHPExcel_Style_Alignment::HORIZONTAL_GENERAL
1228 && isset($this->_cssStyles['.' . $cell->getDataType()]['text-align']))
1229 {
1230 $cssClass['text-align'] = $this->_cssStyles['.' . $cell->getDataType()]['text-align'];
1231 }
1232 }
1233 }
1234
1235 // Hyperlink?
1236 if ($pSheet->hyperlinkExists($coordinate) && !$pSheet->getHyperlink($coordinate)->isInternal()) {
1237 $cellData = '<a href="' . htmlspecialchars($pSheet->getHyperlink($coordinate)->getUrl()) . '" title="' . htmlspecialchars($pSheet->getHyperlink($coordinate)->getTooltip()) . '">' . $cellData . '</a>';
1238 }
1239
1240 // Should the cell be written or is it swallowed by a rowspan or colspan?
1241 $writeCell = ! ( isset($this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])
1242 && $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum] );
1243
1244 // Colspan and Rowspan
1245 $colspan = 1;
1246 $rowspan = 1;
1247 if (isset($this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])) {
1248 $spans = $this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum];
1249 $rowSpan = $spans['rowspan'];
1250 $colSpan = $spans['colspan'];
1251
1252 // Also apply style from last cell in merge to fix borders -
1253 // relies on !important for non-none border declarations in _createCSSStyleBorder
1254 $endCellCoord = PHPExcel_Cell::stringFromColumnIndex($colNum + $colSpan - 1) . ($pRow + $rowSpan);
1255 if (!$this->_useInlineCss) {
1256 $cssClass .= ' style' . $pSheet->getCell($endCellCoord)->getXfIndex();
1257 }
1258 }
1259
1260 // Write
1261 if ($writeCell) {
1262 // Column start
1263 $html .= ' <' . $cellType;
1264 if (!$this->_useInlineCss) {
1265 $html .= ' class="' . $cssClass . '"';
1266 } else {
1267 //** Necessary redundant code for the sake of PHPExcel_Writer_PDF **
1268 // We must explicitly write the width of the <td> element because TCPDF
1269 // does not recognize e.g. <col style="width:42pt">
1270 $width = 0;
1271 $i = $colNum - 1;
1272 $e = $colNum + $colSpan - 1;
1273 while($i++ < $e) {
1274 if (isset($this->_columnWidths[$sheetIndex][$i])) {
1275 $width += $this->_columnWidths[$sheetIndex][$i];
1276 }
1277 }
1278 $cssClass['width'] = $width . 'pt';
1279
1280 // We must also explicitly write the height of the <td> element because TCPDF
1281 // does not recognize e.g. <tr style="height:50pt">
1282 if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'])) {
1283 $height = $this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'];
1284 $cssClass['height'] = $height;
1285 }
1286 //** end of redundant code **
1287
1288 $html .= ' style="' . $this->_assembleCSS($cssClass) . '"';
1289 }
1290 if ($colSpan > 1) {
1291 $html .= ' colspan="' . $colSpan . '"';
1292 }
1293 if ($rowSpan > 1) {
1294 $html .= ' rowspan="' . $rowSpan . '"';
1295 }
1296 $html .= '>';
1297
1298 // Image?
1299 $html .= $this->_writeImageInCell($pSheet, $coordinate);
1300
1301 // Chart?
1302 if ($this->_includeCharts) {
1303 $html .= $this->_writeChartInCell($pSheet, $coordinate);
1304 }
1305
1306 // Cell data
1307 $html .= $cellData;
1308
1309 // Column end
1310 $html .= '</'.$cellType.'>' . PHP_EOL;
1311 }
1312
1313 // Next column
1314 ++$colNum;
1315 }
1316
1317 // Write row end
1318 $html .= ' </tr>' . PHP_EOL;
1319
1320 // Return
1321 return $html;
1322 } else {
1323 throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
1324 }
1325 }
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
static toFormattedString($value='0', $format=PHPExcel_Style_NumberFormat::FORMAT_GENERAL, $callBack=null)
Convert a value in a pre-defined format to a PHP string.
getBreaks()
Get breaks.
Definition: Worksheet.php:1675
getCell($pCoordinate='A1')
Get cell at a specific coordinate.
Definition: Worksheet.php:1153
getHyperlink($pCellCoordinate='A1')
Get hyperlink.
Definition: Worksheet.php:2674
hyperlinkExists($pCoordinate='A1')
Hyperlink at a specific coordinate exists?
Definition: Worksheet.php:2709
getParent()
Get parent.
Definition: Worksheet.php:786
_generateTableFooter()
Generate table footer.
Definition: HTML.php:1066
_generateTableHeader($pSheet)
Generate table header.
Definition: HTML.php:1021
_assembleCSS($pValue=array())
Takes array where of CSS properties / values and converts to CSS string.
Definition: HTML.php:1333
_createCSSStyleFont(PHPExcel_Style_Font $pStyle)
Create CSS style (PHPExcel_Style_Font)
Definition: HTML.php:918
$style
Definition: example_012.php:70

References $html, $style, _assembleCSS(), _createCSSStyleFont(), _generateTableFooter(), _generateTableHeader(), _writeChartInCell(), _writeImageInCell(), PHPExcel_Worksheet\getBreaks(), PHPExcel_Worksheet\getCell(), PHPExcel_Worksheet\getHyperlink(), PHPExcel_Worksheet\getParent(), PHPExcel_Style_Alignment\HORIZONTAL_GENERAL, PHPExcel_Worksheet\hyperlinkExists(), PHP_EOL, PHPExcel_Cell\stringFromColumnIndex(), and PHPExcel_Style_NumberFormat\toFormattedString().

Referenced by generateSheetData().

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

◆ _generateTableFooter()

PHPExcel_Writer_HTML::_generateTableFooter ( )
private

Generate table footer.

Exceptions
PHPExcel_Writer_Exception

Definition at line 1066 of file HTML.php.

1066 {
1067 // Construct HTML
1068 $html = '';
1069 $html .= ' </table>' . PHP_EOL;
1070
1071 // Return
1072 return $html;
1073 }

References $html, and PHP_EOL.

Referenced by _generateRow(), and generateSheetData().

+ Here is the caller graph for this function:

◆ _generateTableHeader()

PHPExcel_Writer_HTML::_generateTableHeader (   $pSheet)
private

Generate table header.

Parameters
PHPExcel_Worksheet$pSheetThe worksheet for the table we are writing
Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 1021 of file HTML.php.

1021 {
1022 $sheetIndex = $pSheet->getParent()->getIndex($pSheet);
1023
1024 // Construct HTML
1025 $html = '';
1026 $html .= $this->_setMargins($pSheet);
1027
1028 if (!$this->_useInlineCss) {
1029 $gridlines = $pSheet->getShowGridlines() ? ' gridlines' : '';
1030 $html .= ' <table border="0" cellpadding="0" cellspacing="0" id="sheet' . $sheetIndex . '" class="sheet' . $sheetIndex . $gridlines . '">' . PHP_EOL;
1031 } else {
1032 $style = isset($this->_cssStyles['table']) ?
1033 $this->_assembleCSS($this->_cssStyles['table']) : '';
1034
1035 if ($this->_isPdf && $pSheet->getShowGridlines()) {
1036 $html .= ' <table border="1" cellpadding="1" id="sheet' . $sheetIndex . '" cellspacing="1" style="' . $style . '">' . PHP_EOL;
1037 } else {
1038 $html .= ' <table border="0" cellpadding="1" id="sheet' . $sheetIndex . '" cellspacing="0" style="' . $style . '">' . PHP_EOL;
1039 }
1040 }
1041
1042 // Write <col> elements
1043 $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1;
1044 $i = -1;
1045 while($i++ < $highestColumnIndex) {
1046 if (!$this->_isPdf) {
1047 if (!$this->_useInlineCss) {
1048 $html .= ' <col class="col' . $i . '">' . PHP_EOL;
1049 } else {
1050 $style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) ?
1051 $this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) : '';
1052 $html .= ' <col style="' . $style . '">' . PHP_EOL;
1053 }
1054 }
1055 }
1056
1057 // Return
1058 return $html;
1059 }
_setMargins(PHPExcel_Worksheet $pSheet)
Definition: HTML.php:1525

References $html, $style, _assembleCSS(), _setMargins(), PHPExcel_Cell\columnIndexFromString(), and PHP_EOL.

Referenced by _generateRow(), and generateSheetData().

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

◆ _mapBorderStyle()

PHPExcel_Writer_HTML::_mapBorderStyle (   $borderStyle)
private

Map border style.

Parameters
int$borderStyleSheet index
Returns
string

Definition at line 230 of file HTML.php.

230 {
231 switch ($borderStyle) {
232 case PHPExcel_Style_Border::BORDER_NONE: return 'none';
233 case PHPExcel_Style_Border::BORDER_DASHDOT: return '1px dashed';
234 case PHPExcel_Style_Border::BORDER_DASHDOTDOT: return '1px dotted';
235 case PHPExcel_Style_Border::BORDER_DASHED: return '1px dashed';
236 case PHPExcel_Style_Border::BORDER_DOTTED: return '1px dotted';
237 case PHPExcel_Style_Border::BORDER_DOUBLE: return '3px double';
238 case PHPExcel_Style_Border::BORDER_HAIR: return '1px solid';
239 case PHPExcel_Style_Border::BORDER_MEDIUM: return '2px solid';
240 case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT: return '2px dashed';
241 case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT: return '2px dotted';
242 case PHPExcel_Style_Border::BORDER_MEDIUMDASHED: return '2px dashed';
243 case PHPExcel_Style_Border::BORDER_SLANTDASHDOT: return '2px dashed';
244 case PHPExcel_Style_Border::BORDER_THICK: return '3px solid';
245 case PHPExcel_Style_Border::BORDER_THIN: return '1px solid';
246 default: return '1px solid'; // map others to thin
247 }
248 }
const BORDER_MEDIUMDASHDOTDOT
Definition: Border.php:48
const BORDER_MEDIUMDASHED
Definition: Border.php:49
const BORDER_SLANTDASHDOT
Definition: Border.php:50
const BORDER_MEDIUMDASHDOT
Definition: Border.php:47
const BORDER_DASHDOTDOT
Definition: Border.php:41

References PHPExcel_Style_Border\BORDER_DASHDOT, PHPExcel_Style_Border\BORDER_DASHDOTDOT, PHPExcel_Style_Border\BORDER_DASHED, PHPExcel_Style_Border\BORDER_DOTTED, PHPExcel_Style_Border\BORDER_DOUBLE, PHPExcel_Style_Border\BORDER_HAIR, PHPExcel_Style_Border\BORDER_MEDIUM, PHPExcel_Style_Border\BORDER_MEDIUMDASHDOT, PHPExcel_Style_Border\BORDER_MEDIUMDASHDOTDOT, PHPExcel_Style_Border\BORDER_MEDIUMDASHED, PHPExcel_Style_Border\BORDER_NONE, PHPExcel_Style_Border\BORDER_SLANTDASHDOT, PHPExcel_Style_Border\BORDER_THICK, and PHPExcel_Style_Border\BORDER_THIN.

Referenced by _createCSSStyleBorder().

+ Here is the caller graph for this function:

◆ _mapHAlign()

PHPExcel_Writer_HTML::_mapHAlign (   $hAlign)
private

Map HAlign.

Parameters
string$hAlignHorizontal alignment
Returns
string|false

Definition at line 212 of file HTML.php.

212 {
213 switch ($hAlign) {
220 default: return false;
221 }
222 }
const HORIZONTAL_CENTER_CONTINUOUS
Definition: Alignment.php:43

References PHPExcel_Style_Alignment\HORIZONTAL_CENTER, PHPExcel_Style_Alignment\HORIZONTAL_CENTER_CONTINUOUS, PHPExcel_Style_Alignment\HORIZONTAL_GENERAL, PHPExcel_Style_Alignment\HORIZONTAL_JUSTIFY, PHPExcel_Style_Alignment\HORIZONTAL_LEFT, and PHPExcel_Style_Alignment\HORIZONTAL_RIGHT.

Referenced by _createCSSStyleAlignment().

+ Here is the caller graph for this function:

◆ _mapVAlign()

PHPExcel_Writer_HTML::_mapVAlign (   $vAlign)
private

Map VAlign.

Parameters
string$vAlignVertical alignment
Returns
string

Definition at line 196 of file HTML.php.

196 {
197 switch ($vAlign) {
198 case PHPExcel_Style_Alignment::VERTICAL_BOTTOM: return 'bottom';
201 case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY: return 'middle';
202 default: return 'baseline';
203 }
204 }

References PHPExcel_Style_Alignment\VERTICAL_BOTTOM, PHPExcel_Style_Alignment\VERTICAL_CENTER, PHPExcel_Style_Alignment\VERTICAL_JUSTIFY, and PHPExcel_Style_Alignment\VERTICAL_TOP.

Referenced by _createCSSStyleAlignment().

+ Here is the caller graph for this function:

◆ _setMargins()

PHPExcel_Writer_HTML::_setMargins ( PHPExcel_Worksheet  $pSheet)
private

Definition at line 1525 of file HTML.php.

1525 {
1526 $htmlPage = '@page { ';
1527 $htmlBody = 'body { ';
1528
1529 $left = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft()) . 'in; ';
1530 $htmlPage .= 'left-margin: ' . $left;
1531 $htmlBody .= 'left-margin: ' . $left;
1532 $right = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getRight()) . 'in; ';
1533 $htmlPage .= 'right-margin: ' . $right;
1534 $htmlBody .= 'right-margin: ' . $right;
1535 $top = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getTop()) . 'in; ';
1536 $htmlPage .= 'top-margin: ' . $top;
1537 $htmlBody .= 'top-margin: ' . $top;
1538 $bottom = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom()) . 'in; ';
1539 $htmlPage .= 'bottom-margin: ' . $bottom;
1540 $htmlBody .= 'bottom-margin: ' . $bottom;
1541
1542 $htmlPage .= "}\n";
1543 $htmlBody .= "}\n";
1544
1545 return "<style>\n" . $htmlPage . $htmlBody . "</style>\n";
1546 }
static FormatNumber($value)
Formats a numeric value as a string for output in various output writers forcing point as decimal sep...
Definition: String.php:416
getPageMargins()
Get page margins.
Definition: Worksheet.php:936

References PHPExcel_Shared_String\FormatNumber(), and PHPExcel_Worksheet\getPageMargins().

Referenced by _generateTableHeader().

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

◆ _writeChartInCell()

PHPExcel_Writer_HTML::_writeChartInCell ( PHPExcel_Worksheet  $pSheet,
  $coordinates 
)
private

Generate chart tag in cell.

Parameters
PHPExcel_Worksheet$pSheetPHPExcel_Worksheet
string$coordinatesCell coordinates
Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 634 of file HTML.php.

634 {
635 // Construct HTML
636 $html = '';
637
638 // Write charts
639 foreach ($pSheet->getChartCollection() as $chart) {
640 if ($chart instanceof PHPExcel_Chart) {
641 $chartCoordinates = $chart->getTopLeftPosition();
642 if ($chartCoordinates['cell'] == $coordinates) {
643 $chartFileName = PHPExcel_Shared_File::sys_get_temp_dir().'/'.uniqid().'.png';
644 if (!$chart->render($chartFileName)) {
645 return;
646 }
647
648 $html .= PHP_EOL;
649 $imageDetails = getimagesize($chartFileName);
650 if ($fp = fopen($chartFileName,"rb", 0)) {
651 $picture = fread($fp,filesize($chartFileName));
652 fclose($fp);
653 // base64 encode the binary data, then break it
654 // into chunks according to RFC 2045 semantics
655 $base64 = chunk_split(base64_encode($picture));
656 $imageData = 'data:'.$imageDetails['mime'].';base64,' . $base64;
657
658 $html .= '<div style="position: relative;">';
659 $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 . '" border="0" />' . PHP_EOL;
660 $html .= '</div>';
661
662 unlink($chartFileName);
663 }
664 }
665 }
666 }
667
668 // Return
669 return $html;
670 }
static sys_get_temp_dir()
Get the systems temporary directory.
Definition: File.php:135

References $chart, $html, PHPExcel_Worksheet\getChartCollection(), PHP_EOL, and PHPExcel_Shared_File\sys_get_temp_dir().

Referenced by _extendRowsForChartsAndImages(), and _generateRow().

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

◆ _writeImageInCell()

PHPExcel_Writer_HTML::_writeImageInCell ( PHPExcel_Worksheet  $pSheet,
  $coordinates 
)
private

Generate image tag in cell.

Parameters
PHPExcel_Worksheet$pSheetPHPExcel_Worksheet
string$coordinatesCell coordinates
Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 569 of file HTML.php.

569 {
570 // Construct HTML
571 $html = '';
572
573 // Write images
574 foreach ($pSheet->getDrawingCollection() as $drawing) {
575 if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
576 if ($drawing->getCoordinates() == $coordinates) {
577 $filename = $drawing->getPath();
578
579 // Strip off eventual '.'
580 if (substr($filename, 0, 1) == '.') {
581 $filename = substr($filename, 1);
582 }
583
584 // Prepend images root
585 $filename = $this->getImagesRoot() . $filename;
586
587 // Strip off eventual '.'
588 if (substr($filename, 0, 1) == '.' && substr($filename, 0, 2) != './') {
589 $filename = substr($filename, 1);
590 }
591
592 // Convert UTF8 data to PCDATA
593 $filename = htmlspecialchars($filename);
594
595 $html .= PHP_EOL;
596 if ((!$this->_embedImages) || ($this->_isPdf)) {
597 $imageData = $filename;
598 } else {
599 $imageDetails = getimagesize($filename);
600 if ($fp = fopen($filename,"rb", 0)) {
601 $picture = fread($fp,filesize($filename));
602 fclose($fp);
603 // base64 encode the binary data, then break it
604 // into chunks according to RFC 2045 semantics
605 $base64 = chunk_split(base64_encode($picture));
606 $imageData = 'data:'.$imageDetails['mime'].';base64,' . $base64;
607 } else {
608 $imageData = $filename;
609 }
610 }
611
612 $html .= '<div style="position: relative;">';
613 $html .= '<img style="position: absolute; z-index: 1; left: ' .
614 $drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: ' .
615 $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="' .
616 $imageData . '" border="0" />';
617 $html .= '</div>';
618 }
619 }
620 }
621
622 // Return
623 return $html;
624 }
getImagesRoot()
Get images root.
Definition: HTML.php:1349

References $filename, $html, PHPExcel_Worksheet\getDrawingCollection(), getImagesRoot(), and PHP_EOL.

Referenced by _extendRowsForChartsAndImages(), and _generateRow().

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

◆ buildCSS()

PHPExcel_Writer_HTML::buildCSS (   $generateSurroundingHTML = true)

Build CSS styles.

Parameters
boolean$generateSurroundingHTMLGenerate surrounding HTML style? (html { })
Returns
array
Exceptions
PHPExcel_Writer_Exception

Definition at line 720 of file HTML.php.

720 {
721 // PHPExcel object known?
722 if (is_null($this->_phpExcel)) {
723 throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
724 }
725
726 // Cached?
727 if (!is_null($this->_cssStyles)) {
728 return $this->_cssStyles;
729 }
730
731 // Ensure that spans have been calculated
732 if (!$this->_spansAreCalculated) {
733 $this->_calculateSpans();
734 }
735
736 // Construct CSS
737 $css = array();
738
739 // Start styles
740 if ($generateSurroundingHTML) {
741 // html { }
742 $css['html']['font-family'] = 'Calibri, Arial, Helvetica, sans-serif';
743 $css['html']['font-size'] = '11pt';
744 $css['html']['background-color'] = 'white';
745 }
746
747
748 // table { }
749 $css['table']['border-collapse'] = 'collapse';
750 if (!$this->_isPdf) {
751 $css['table']['page-break-after'] = 'always';
752 }
753
754 // .gridlines td { }
755 $css['.gridlines td']['border'] = '1px dotted black';
756 $css['.gridlines th']['border'] = '1px dotted black';
757
758 // .b {}
759 $css['.b']['text-align'] = 'center'; // BOOL
760
761 // .e {}
762 $css['.e']['text-align'] = 'center'; // ERROR
763
764 // .f {}
765 $css['.f']['text-align'] = 'right'; // FORMULA
766
767 // .inlineStr {}
768 $css['.inlineStr']['text-align'] = 'left'; // INLINE
769
770 // .n {}
771 $css['.n']['text-align'] = 'right'; // NUMERIC
772
773 // .s {}
774 $css['.s']['text-align'] = 'left'; // STRING
775
776 // Calculate cell style hashes
777 foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) {
778 $css['td.style' . $index] = $this->_createCSSStyle( $style );
779 $css['th.style' . $index] = $this->_createCSSStyle( $style );
780 }
781
782 // Fetch sheets
783 $sheets = array();
784 if (is_null($this->_sheetIndex)) {
785 $sheets = $this->_phpExcel->getAllSheets();
786 } else {
787 $sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
788 }
789
790 // Build styles per sheet
791 foreach ($sheets as $sheet) {
792 // Calculate hash code
793 $sheetIndex = $sheet->getParent()->getIndex($sheet);
794
795 // Build styles
796 // Calculate column widths
797 $sheet->calculateColumnWidths();
798
799 // col elements, initialize
800 $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
801 $column = -1;
802 while($column++ < $highestColumnIndex) {
803 $this->_columnWidths[$sheetIndex][$column] = 42; // approximation
804 $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt';
805 }
806
807 // col elements, loop through columnDimensions and set width
808 foreach ($sheet->getColumnDimensions() as $columnDimension) {
809 if (($width = PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->_defaultFont)) >= 0) {
811 $column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
812 $this->_columnWidths[$sheetIndex][$column] = $width;
813 $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = $width . 'pt';
814
815 if ($columnDimension->getVisible() === false) {
816 $css['table.sheet' . $sheetIndex . ' col.col' . $column]['visibility'] = 'collapse';
817 $css['table.sheet' . $sheetIndex . ' col.col' . $column]['*display'] = 'none'; // target IE6+7
818 }
819 }
820 }
821
822 // Default row height
823 $rowDimension = $sheet->getDefaultRowDimension();
824
825 // table.sheetN tr { }
826 $css['table.sheet' . $sheetIndex . ' tr'] = array();
827
828 if ($rowDimension->getRowHeight() == -1) {
829 $pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
830 } else {
831 $pt_height = $rowDimension->getRowHeight();
832 }
833 $css['table.sheet' . $sheetIndex . ' tr']['height'] = $pt_height . 'pt';
834 if ($rowDimension->getVisible() === false) {
835 $css['table.sheet' . $sheetIndex . ' tr']['display'] = 'none';
836 $css['table.sheet' . $sheetIndex . ' tr']['visibility'] = 'hidden';
837 }
838
839 // Calculate row heights
840 foreach ($sheet->getRowDimensions() as $rowDimension) {
841 $row = $rowDimension->getRowIndex() - 1;
842
843 // table.sheetN tr.rowYYYYYY { }
844 $css['table.sheet' . $sheetIndex . ' tr.row' . $row] = array();
845
846 if ($rowDimension->getRowHeight() == -1) {
847 $pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
848 } else {
849 $pt_height = $rowDimension->getRowHeight();
850 }
851 $css['table.sheet' . $sheetIndex . ' tr.row' . $row]['height'] = $pt_height . 'pt';
852 if ($rowDimension->getVisible() === false) {
853 $css['table.sheet' . $sheetIndex . ' tr.row' . $row]['display'] = 'none';
854 $css['table.sheet' . $sheetIndex . ' tr.row' . $row]['visibility'] = 'hidden';
855 }
856 }
857 }
858
859 // Cache
860 if (is_null($this->_cssStyles)) {
861 $this->_cssStyles = $css;
862 }
863
864 // Return
865 return $css;
866 }
$column
Definition: 39dropdown.php:62
static cellDimensionToPixels($pValue=0, PHPExcel_Style_Font $pDefaultFont)
Convert column width from (intrinsic) Excel units to pixels.
Definition: Drawing.php:99
static pixelsToPoints($pValue=0)
Convert pixels to points.
Definition: Drawing.php:130
static getDefaultRowHeightByFont(PHPExcel_Style_Font $font)
Get the effective row height for rows without a row dimension or rows with height -1 For example,...
Definition: Font.php:603
_calculateSpans()
Calculate information about HTML colspan and rowspan which is not always the same as Excel's.
Definition: HTML.php:1438
_createCSSStyle(PHPExcel_Style $pStyle)
Create CSS style.
Definition: HTML.php:874

References $_cssStyles, $column, $row, $style, _calculateSpans(), _createCSSStyle(), PHPExcel_Shared_Drawing\cellDimensionToPixels(), PHPExcel_Cell\columnIndexFromString(), PHPExcel_Shared_Font\getDefaultRowHeightByFont(), and PHPExcel_Shared_Drawing\pixelsToPoints().

Referenced by generateStyles(), PHPExcel_Writer_PDF_Core\prepareForSave(), and save().

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

◆ formatColor()

PHPExcel_Writer_HTML::formatColor (   $pValue,
  $pFormat 
)

Add color to formatted string as inline style.

Parameters
string$pValuePlain formatted value without color
string$pFormatFormat code
Returns
string

Definition at line 1411 of file HTML.php.

1412 {
1413 // Color information, e.g. [Red] is always at the beginning
1414 $color = null; // initialize
1415 $matches = array();
1416
1417 $color_regex = '/^\\[[a-zA-Z]+\\]/';
1418 if (preg_match($color_regex, $pFormat, $matches)) {
1419 $color = str_replace('[', '', $matches[0]);
1420 $color = str_replace(']', '', $color);
1421 $color = strtolower($color);
1422 }
1423
1424 // convert to PCDATA
1425 $value = htmlspecialchars($pValue);
1426
1427 // color span tag
1428 if ($color !== null) {
1429 $value = '<span style="color:' . $color . '">' . $value . '</span>';
1430 }
1431
1432 return $value;
1433 }

◆ generateHTMLFooter()

PHPExcel_Writer_HTML::generateHTMLFooter ( )

Generate HTML footer.

Definition at line 1004 of file HTML.php.

1004 {
1005 // Construct HTML
1006 $html = '';
1007 $html .= ' </body>' . PHP_EOL;
1008 $html .= '</html>' . PHP_EOL;
1009
1010 // Return
1011 return $html;
1012 }

References $html, and PHP_EOL.

Referenced by save(), PHPExcel_Writer_PDF_DomPDF\save(), PHPExcel_Writer_PDF_mPDF\save(), and PHPExcel_Writer_PDF_tcPDF\save().

+ Here is the caller graph for this function:

◆ generateHTMLHeader()

PHPExcel_Writer_HTML::generateHTMLHeader (   $pIncludeStyles = false)

Generate HTML header.

Parameters
boolean$pIncludeStylesInclude styles?
Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 305 of file HTML.php.

305 {
306 // PHPExcel object known?
307 if (is_null($this->_phpExcel)) {
308 throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
309 }
310
311 // Construct HTML
312 $properties = $this->_phpExcel->getProperties();
313 $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . PHP_EOL;
314 $html .= '<!-- Generated by PHPExcel - http://www.phpexcel.net -->' . PHP_EOL;
315 $html .= '<html>' . PHP_EOL;
316 $html .= ' <head>' . PHP_EOL;
317 $html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . PHP_EOL;
318 if ($properties->getTitle() > '')
319 $html .= ' <title>' . htmlspecialchars($properties->getTitle()) . '</title>' . PHP_EOL;
320
321 if ($properties->getCreator() > '')
322 $html .= ' <meta name="author" content="' . htmlspecialchars($properties->getCreator()) . '" />' . PHP_EOL;
323 if ($properties->getTitle() > '')
324 $html .= ' <meta name="title" content="' . htmlspecialchars($properties->getTitle()) . '" />' . PHP_EOL;
325 if ($properties->getDescription() > '')
326 $html .= ' <meta name="description" content="' . htmlspecialchars($properties->getDescription()) . '" />' . PHP_EOL;
327 if ($properties->getSubject() > '')
328 $html .= ' <meta name="subject" content="' . htmlspecialchars($properties->getSubject()) . '" />' . PHP_EOL;
329 if ($properties->getKeywords() > '')
330 $html .= ' <meta name="keywords" content="' . htmlspecialchars($properties->getKeywords()) . '" />' . PHP_EOL;
331 if ($properties->getCategory() > '')
332 $html .= ' <meta name="category" content="' . htmlspecialchars($properties->getCategory()) . '" />' . PHP_EOL;
333 if ($properties->getCompany() > '')
334 $html .= ' <meta name="company" content="' . htmlspecialchars($properties->getCompany()) . '" />' . PHP_EOL;
335 if ($properties->getManager() > '')
336 $html .= ' <meta name="manager" content="' . htmlspecialchars($properties->getManager()) . '" />' . PHP_EOL;
337
338 if ($pIncludeStyles) {
339 $html .= $this->generateStyles(true);
340 }
341
342 $html .= ' </head>' . PHP_EOL;
343 $html .= '' . PHP_EOL;
344 $html .= ' <body>' . PHP_EOL;
345
346 // Return
347 return $html;
348 }
generateStyles($generateSurroundingHTML=true)
Generate CSS styles.
Definition: HTML.php:679

References $html, generateStyles(), and PHP_EOL.

Referenced by save(), PHPExcel_Writer_PDF_DomPDF\save(), PHPExcel_Writer_PDF_mPDF\save(), and PHPExcel_Writer_PDF_tcPDF\save().

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

◆ generateNavigation()

PHPExcel_Writer_HTML::generateNavigation ( )

Generate sheet tabs.

Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 475 of file HTML.php.

476 {
477 // PHPExcel object known?
478 if (is_null($this->_phpExcel)) {
479 throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
480 }
481
482 // Fetch sheets
483 $sheets = array();
484 if (is_null($this->_sheetIndex)) {
485 $sheets = $this->_phpExcel->getAllSheets();
486 } else {
487 $sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
488 }
489
490 // Construct HTML
491 $html = '';
492
493 // Only if there are more than 1 sheets
494 if (count($sheets) > 1) {
495 // Loop all sheets
496 $sheetId = 0;
497
498 $html .= '<ul class="navigation">' . PHP_EOL;
499
500 foreach ($sheets as $sheet) {
501 $html .= ' <li class="sheet' . $sheetId . '"><a href="#sheet' . $sheetId . '">' . $sheet->getTitle() . '</a></li>' . PHP_EOL;
502 ++$sheetId;
503 }
504
505 $html .= '</ul>' . PHP_EOL;
506 }
507
508 return $html;
509 }

References $html, and PHP_EOL.

Referenced by save().

+ Here is the caller graph for this function:

◆ generateSheetData()

PHPExcel_Writer_HTML::generateSheetData ( )

Generate sheet data.

Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 356 of file HTML.php.

356 {
357 // PHPExcel object known?
358 if (is_null($this->_phpExcel)) {
359 throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
360 }
361
362 // Ensure that Spans have been calculated?
363 if (!$this->_spansAreCalculated) {
364 $this->_calculateSpans();
365 }
366
367 // Fetch sheets
368 $sheets = array();
369 if (is_null($this->_sheetIndex)) {
370 $sheets = $this->_phpExcel->getAllSheets();
371 } else {
372 $sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
373 }
374
375 // Construct HTML
376 $html = '';
377
378 // Loop all sheets
379 $sheetId = 0;
380 foreach ($sheets as $sheet) {
381 // Write table header
382 $html .= $this->_generateTableHeader($sheet);
383
384 // Get worksheet dimension
385 $dimension = explode(':', $sheet->calculateWorksheetDimension());
386 $dimension[0] = PHPExcel_Cell::coordinateFromString($dimension[0]);
387 $dimension[0][0] = PHPExcel_Cell::columnIndexFromString($dimension[0][0]) - 1;
388 $dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]);
389 $dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1;
390
391 // row min,max
392 $rowMin = $dimension[0][1];
393 $rowMax = $dimension[1][1];
394
395 // calculate start of <tbody>, <thead>
396 $tbodyStart = $rowMin;
397 $theadStart = $theadEnd = 0; // default: no <thead> no </thead>
398 if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
399 $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
400
401 // we can only support repeating rows that start at top row
402 if ($rowsToRepeatAtTop[0] == 1) {
403 $theadStart = $rowsToRepeatAtTop[0];
404 $theadEnd = $rowsToRepeatAtTop[1];
405 $tbodyStart = $rowsToRepeatAtTop[1] + 1;
406 }
407 }
408
409 // Loop through cells
410 $row = $rowMin-1;
411 while($row++ < $rowMax) {
412 // <thead> ?
413 if ($row == $theadStart) {
414 $html .= ' <thead>' . PHP_EOL;
415 $cellType = 'th';
416 }
417
418 // <tbody> ?
419 if ($row == $tbodyStart) {
420 $html .= ' <tbody>' . PHP_EOL;
421 $cellType = 'td';
422 }
423
424 // Write row if there are HTML table cells in it
425 if ( !isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row]) ) {
426 // Start a new rowData
427 $rowData = array();
428 // Loop through columns
429 $column = $dimension[0][0] - 1;
430 while($column++ < $dimension[1][0]) {
431 // Cell exists?
432 if ($sheet->cellExistsByColumnAndRow($column, $row)) {
434 } else {
435 $rowData[$column] = '';
436 }
437 }
438 $html .= $this->_generateRow($sheet, $rowData, $row - 1, $cellType);
439 }
440
441 // </thead> ?
442 if ($row == $theadEnd) {
443 $html .= ' </thead>' . PHP_EOL;
444 }
445 }
446 $html .= $this->_extendRowsForChartsAndImages($sheet, $row);
447
448 // Close table body.
449 $html .= ' </tbody>' . PHP_EOL;
450
451 // Write table footer
452 $html .= $this->_generateTableFooter();
453
454 // Writing PDF?
455 if ($this->_isPdf) {
456 if (is_null($this->_sheetIndex) && $sheetId + 1 < $this->_phpExcel->getSheetCount()) {
457 $html .= '<div style="page-break-before:always" />';
458 }
459 }
460
461 // Next sheet
462 ++$sheetId;
463 }
464
465 // Return
466 return $html;
467 }
_generateRow(PHPExcel_Worksheet $pSheet, $pValues=null, $pRow=0, $cellType='td')
Generate row.
Definition: HTML.php:1084
_extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row)
Definition: HTML.php:511

References $column, $html, $row, _calculateSpans(), _extendRowsForChartsAndImages(), _generateRow(), _generateTableFooter(), _generateTableHeader(), PHPExcel_Cell\columnIndexFromString(), PHPExcel_Cell\coordinateFromString(), PHP_EOL, and PHPExcel_Cell\stringFromColumnIndex().

Referenced by save(), PHPExcel_Writer_PDF_DomPDF\save(), PHPExcel_Writer_PDF_mPDF\save(), and PHPExcel_Writer_PDF_tcPDF\save().

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

◆ generateStyles()

PHPExcel_Writer_HTML::generateStyles (   $generateSurroundingHTML = true)

Generate CSS styles.

Parameters
boolean$generateSurroundingHTMLGenerate surrounding HTML tags? (<style> and </style>)
Returns
string
Exceptions
PHPExcel_Writer_Exception

Definition at line 679 of file HTML.php.

679 {
680 // PHPExcel object known?
681 if (is_null($this->_phpExcel)) {
682 throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
683 }
684
685 // Build CSS
686 $css = $this->buildCSS($generateSurroundingHTML);
687
688 // Construct HTML
689 $html = '';
690
691 // Start styles
692 if ($generateSurroundingHTML) {
693 $html .= ' <style type="text/css">' . PHP_EOL;
694 $html .= ' html { ' . $this->_assembleCSS($css['html']) . ' }' . PHP_EOL;
695 }
696
697 // Write all other styles
698 foreach ($css as $styleName => $styleDefinition) {
699 if ($styleName != 'html') {
700 $html .= ' ' . $styleName . ' { ' . $this->_assembleCSS($styleDefinition) . ' }' . PHP_EOL;
701 }
702 }
703
704 // End styles
705 if ($generateSurroundingHTML) {
706 $html .= ' </style>' . PHP_EOL;
707 }
708
709 // Return
710 return $html;
711 }
buildCSS($generateSurroundingHTML=true)
Build CSS styles.
Definition: HTML.php:720

References $html, _assembleCSS(), buildCSS(), and PHP_EOL.

Referenced by generateHTMLHeader().

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

◆ getEmbedImages()

PHPExcel_Writer_HTML::getEmbedImages ( )

Get embed images.

Returns
boolean

Definition at line 1369 of file HTML.php.

1369 {
1370 return $this->_embedImages;
1371 }

References $_embedImages.

◆ getGenerateSheetNavigationBlock()

PHPExcel_Writer_HTML::getGenerateSheetNavigationBlock ( )

Get sheet index.

Returns
boolean

Definition at line 275 of file HTML.php.

275 {
277 }
$_generateSheetNavigationBlock
Definition: HTML.php:133

References $_generateSheetNavigationBlock.

◆ getImagesRoot()

PHPExcel_Writer_HTML::getImagesRoot ( )

Get images root.

Returns
string

Definition at line 1349 of file HTML.php.

1349 {
1350 return $this->_imagesRoot;
1351 }

References $_imagesRoot.

Referenced by _writeImageInCell().

+ Here is the caller graph for this function:

◆ getSheetIndex()

PHPExcel_Writer_HTML::getSheetIndex ( )

Get sheet index.

Returns
int

Definition at line 255 of file HTML.php.

255 {
256 return $this->_sheetIndex;
257 }

References $_sheetIndex.

Referenced by PHPExcel_Writer_PDF_DomPDF\save(), PHPExcel_Writer_PDF_mPDF\save(), and PHPExcel_Writer_PDF_tcPDF\save().

+ Here is the caller graph for this function:

◆ getUseInlineCss()

PHPExcel_Writer_HTML::getUseInlineCss ( )

Get use inline CSS?

Returns
boolean

Definition at line 1389 of file HTML.php.

1389 {
1390 return $this->_useInlineCss;
1391 }

References $_useInlineCss.

◆ save()

PHPExcel_Writer_HTML::save (   $pFilename = null)

Save PHPExcel to file.

Parameters
string$pFilename
Exceptions
PHPExcel_Writer_Exception

Implements PHPExcel_Writer_IWriter.

Reimplemented in PHPExcel_Writer_PDF_DomPDF, PHPExcel_Writer_PDF_mPDF, and PHPExcel_Writer_PDF_tcPDF.

Definition at line 151 of file HTML.php.

151 {
152 // garbage collect
153 $this->_phpExcel->garbageCollect();
154
155 $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
156 PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
157 $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
159
160 // Build CSS
161 $this->buildCSS(!$this->_useInlineCss);
162
163 // Open file
164 $fileHandle = fopen($pFilename, 'wb+');
165 if ($fileHandle === false) {
166 throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing.");
167 }
168
169 // Write headers
170 fwrite($fileHandle, $this->generateHTMLHeader(!$this->_useInlineCss));
171
172 // Write navigation (tabs)
173 if ((!$this->_isPdf) && ($this->_generateSheetNavigationBlock)) {
174 fwrite($fileHandle, $this->generateNavigation());
175 }
176
177 // Write data
178 fwrite($fileHandle, $this->generateSheetData());
179
180 // Write footer
181 fwrite($fileHandle, $this->generateHTMLFooter());
182
183 // Close file
184 fclose($fileHandle);
185
186 PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
187 PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
188 }
static getInstance(PHPExcel $workbook=NULL)
Get an instance of this class.
static getArrayReturnType()
Return the Array Return Type (Array or Value of first element in the array)
static setArrayReturnType($returnType)
Set the Array Return Type (Array or Value of first element in the array)
generateHTMLFooter()
Generate HTML footer.
Definition: HTML.php:1004
generateNavigation()
Generate sheet tabs.
Definition: HTML.php:475
generateHTMLHeader($pIncludeStyles=false)
Generate HTML header.
Definition: HTML.php:305
generateSheetData()
Generate sheet data.
Definition: HTML.php:356

References buildCSS(), generateHTMLFooter(), generateHTMLHeader(), generateNavigation(), generateSheetData(), PHPExcel_Calculation\getArrayReturnType(), PHPExcel_Calculation\getInstance(), PHPExcel_Calculation\RETURN_ARRAY_AS_VALUE, and PHPExcel_Calculation\setArrayReturnType().

+ Here is the call graph for this function:

◆ setEmbedImages()

PHPExcel_Writer_HTML::setEmbedImages (   $pValue = '.')

Set embed images.

Parameters
boolean$pValue
Returns
PHPExcel_Writer_HTML

Definition at line 1379 of file HTML.php.

1379 {
1380 $this->_embedImages = $pValue;
1381 return $this;
1382 }

◆ setGenerateSheetNavigationBlock()

PHPExcel_Writer_HTML::setGenerateSheetNavigationBlock (   $pValue = true)

Set sheet index.

Parameters
boolean$pValueFlag indicating whether the sheet navigation block should be generated or not
Returns
PHPExcel_Writer_HTML

Definition at line 285 of file HTML.php.

285 {
286 $this->_generateSheetNavigationBlock = (bool) $pValue;
287 return $this;
288 }

◆ setImagesRoot()

PHPExcel_Writer_HTML::setImagesRoot (   $pValue = '.')

Set images root.

Parameters
string$pValue
Returns
PHPExcel_Writer_HTML

Definition at line 1359 of file HTML.php.

1359 {
1360 $this->_imagesRoot = $pValue;
1361 return $this;
1362 }

◆ setSheetIndex()

PHPExcel_Writer_HTML::setSheetIndex (   $pValue = 0)

Set sheet index.

Parameters
int$pValueSheet index
Returns
PHPExcel_Writer_HTML

Definition at line 265 of file HTML.php.

265 {
266 $this->_sheetIndex = $pValue;
267 return $this;
268 }

◆ setUseInlineCss()

PHPExcel_Writer_HTML::setUseInlineCss (   $pValue = false)

Set use inline CSS?

Parameters
boolean$pValue
Returns
PHPExcel_Writer_HTML

Definition at line 1399 of file HTML.php.

1399 {
1400 $this->_useInlineCss = $pValue;
1401 return $this;
1402 }

Referenced by PHPExcel_Writer_PDF_Core\__construct().

+ Here is the caller graph for this function:

◆ writeAllSheets()

PHPExcel_Writer_HTML::writeAllSheets ( )

Write all sheets (resets sheetIndex to NULL)

Definition at line 293 of file HTML.php.

293 {
294 $this->_sheetIndex = null;
295 return $this;
296 }

Field Documentation

◆ $_columnWidths

PHPExcel_Writer_HTML::$_columnWidths = null
private

Definition at line 84 of file HTML.php.

◆ $_cssStyles

PHPExcel_Writer_HTML::$_cssStyles = null
private

Definition at line 77 of file HTML.php.

Referenced by buildCSS().

◆ $_defaultFont

PHPExcel_Writer_HTML::$_defaultFont
private

Definition at line 91 of file HTML.php.

◆ $_embedImages

PHPExcel_Writer_HTML::$_embedImages = FALSE
private

Definition at line 63 of file HTML.php.

Referenced by getEmbedImages().

◆ $_generateSheetNavigationBlock

PHPExcel_Writer_HTML::$_generateSheetNavigationBlock = true
private

Definition at line 133 of file HTML.php.

Referenced by getGenerateSheetNavigationBlock().

◆ $_imagesRoot

PHPExcel_Writer_HTML::$_imagesRoot = '.'
private

Definition at line 56 of file HTML.php.

Referenced by getImagesRoot().

◆ $_isBaseCell

PHPExcel_Writer_HTML::$_isBaseCell = array()
private

Definition at line 112 of file HTML.php.

◆ $_isPdf

PHPExcel_Writer_HTML::$_isPdf = false
protected

Definition at line 126 of file HTML.php.

◆ $_isSpannedCell

PHPExcel_Writer_HTML::$_isSpannedCell = array()
private

Definition at line 105 of file HTML.php.

◆ $_isSpannedRow

PHPExcel_Writer_HTML::$_isSpannedRow = array()
private

Definition at line 119 of file HTML.php.

◆ $_phpExcel

PHPExcel_Writer_HTML::$_phpExcel
protected

Definition at line 42 of file HTML.php.

◆ $_sheetIndex

PHPExcel_Writer_HTML::$_sheetIndex = 0
private

Definition at line 49 of file HTML.php.

Referenced by getSheetIndex().

◆ $_spansAreCalculated

PHPExcel_Writer_HTML::$_spansAreCalculated = false
private

Definition at line 98 of file HTML.php.

◆ $_useInlineCss

PHPExcel_Writer_HTML::$_useInlineCss = false
private

Definition at line 70 of file HTML.php.

Referenced by getUseInlineCss().


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