Mpdf extends Pdf
Table of Contents
- BODY_LINE = ' <body>' . PHP_EOL
- BORDER_ARR = [PhpOfficePhpSpreadsheetStyleBorder::BORDER_NONE => 'none', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DASHDOT => '1px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DASHDOTDOT => '1px dotted', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DASHED => '1px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DOTTED => '1px dotted', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DOUBLE => '3px double', PhpOfficePhpSpreadsheetStyleBorder::BORDER_HAIR => '1px solid', PhpOfficePhpSpreadsheetStyleBorder::BORDER_MEDIUM => '2px solid', PhpOfficePhpSpreadsheetStyleBorder::BORDER_MEDIUMDASHDOT => '2px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_MEDIUMDASHDOTDOT => '2px dotted', PhpOfficePhpSpreadsheetStyleBorder::BORDER_SLANTDASHDOT => '2px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_THICK => '3px solid']
- CUSTOM_TO_META = [PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_BOOLEAN => 'bool', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_DATE => 'date', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_FLOAT => 'float', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_INTEGER => 'int', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_STRING => 'string']
- $embedImages : bool
- embed images, or link to images.
- $fileHandle : resource
- $font : string
- Font.
- $includeCharts : bool
- Write charts that are defined in the workbook? Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object.
- $isMPdf : bool
- $isPdf : bool
- Is the current writer creating PDF?
- $orientation : string|null
- Orientation (Over-ride).
- $paperSize : int|null
- Paper size (Over-ride).
- $paperSizes : array<string|int, mixed>
- Paper Sizes xRef List.
- $preCalculateFormulas : bool
- Pre-calculate formulas Forces PhpSpreadsheet to 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.
- $spreadsheet : Spreadsheet
- Spreadsheet object.
- $tempDir : string
- Temporary storage directory.
- $columnWidths : array<string|int, mixed>
- Array of column widths in points.
- $cssStyles : array<string|int, mixed>
- Array of CSS styles.
- $defaultFont : Font
- Default font.
- $diskCachingDirectory : string
- Disk caching directory.
- $editHtmlCallback : null|callable
- Callback for editing generated html.
- $generateSheetNavigationBlock : bool
- Generate the Navigation block.
- $imagesRoot : string
- Images root.
- $isBaseCell : array<string|int, mixed>
- Excel cells that are upper-left corner in a cell merge.
- $isSpannedCell : array<string|int, mixed>
- Excel cells that should not be written as HTML cells.
- $isSpannedRow : array<string|int, mixed>
- Excel rows that should not be written as HTML rows.
- $sheetIndex : null|int
- Sheet index to write.
- $shouldCloseFile : bool
- $spansAreCalculated : bool
- Flag whether spans have been calculated.
- $useDiskCaching : bool
- Use disk caching where possible?
- $useEmbeddedCSS : bool
- Use embedded CSS?
- $useInlineCss : bool
- Use inline CSS?
- __construct() : mixed
- Create a new HTML.
- buildCSS() : array<string|int, mixed>
- Build CSS styles.
- formatColor() : string
- Add color to formatted string as inline style.
- generateHtmlAll() : string
- Save Spreadsheet as html to variable.
- generateHTMLFooter() : string
- Generate HTML footer.
- generateHTMLHeader() : string
- Generate HTML header.
- generateNavigation() : string
- Generate sheet tabs.
- generateSheetData() : string
- Generate sheet data.
- generateStyles() : string
- Generate CSS styles.
- getDiskCachingDirectory() : string
- Get disk caching directory.
- getEmbedImages() : bool
- Get embed images.
- getFont() : string
- Get Font.
- getGenerateSheetNavigationBlock() : bool
- Get sheet index.
- getImagesRoot() : string
- Get images root.
- getIncludeCharts() : bool
- Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object.
- getOrientation() : string|null
- getPaperSize() : int|null
- Get Paper Size.
- getPreCalculateFormulas() : bool
- 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. This is faster for saving in PhpSpreadsheet, but slower when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself.
- getSheetIndex() : int|null
- Get sheet index.
- getTempDir() : string
- Get temporary storage directory.
- getUseDiskCaching() : bool
- Get use disk caching where possible?
- getUseEmbeddedCSS() : bool
- Get use embedded CSS?
- getUseInlineCss() : bool
- Get use inline CSS?
- openFileHandle() : void
- Open file handle.
- save() : void
- Save Spreadsheet to file.
- setEditHtmlCallback() : void
- Set a callback to edit the entire HTML.
- setEmbedImages() : $this
- Set embed images.
- setFont() : $this
- Set font. Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'.
- setGenerateSheetNavigationBlock() : $this
- Set sheet index.
- setImagesRoot() : $this
- Set images root.
- setIncludeCharts() : IWriter
- Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.
- setOrientation() : self
- Set Orientation.
- setPaperSize() : self
- Set Paper Size.
- setPreCalculateFormulas() : IWriter
- 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.
- setSheetIndex() : $this
- Set sheet index.
- setTempDir() : self
- Set temporary storage directory.
- setUseDiskCaching() : IWriter
- Set use disk caching where possible?
- setUseEmbeddedCSS() : $this
- Set use embedded CSS?
- setUseInlineCss() : $this
- Set use inline CSS?
- winFileToUrl() : string
- Convert Windows file name to file protocol URL.
- writeAllSheets() : $this
- Write all sheets (resets sheetIndex to NULL).
- createExternalWriterInstance() : Mpdf
- Gets the implementation of external PDF library that should be used.
- maybeCloseFileHandle() : void
- Close file handle only if we opened it ourselves.
- prepareForSave() : resource
- Save Spreadsheet to PDF file, pre-save.
- processFlags() : void
- restoreStateAfterSave() : void
- Save PhpSpreadsheet to PDF file, post-save.
- assembleCSS() : string
- Takes array where of CSS properties / values and converts to CSS string.
- buildCssPerSheet() : void
- buildCssRowHeights() : void
- calculateSpans() : void
- Calculate information about HTML colspan and rowspan which is not always the same as Excel's.
- calculateSpansOmitRows() : void
- createCSSStyle() : array<string|int, mixed>
- Create CSS style.
- createCSSStyleAlignment() : array<string|int, mixed>
- Create CSS style.
- createCSSStyleBorder() : string
- Create CSS style.
- createCSSStyleBorders() : array<string|int, mixed>
- Create CSS style.
- createCSSStyleFill() : array<string|int, mixed>
- Create CSS style (Fill).
- createCSSStyleFont() : array<string|int, mixed>
- Create CSS style.
- extendRowsForCharts() : array<string|int, mixed>
- Extend Row if chart is placed after nominal end of row.
- extendRowsForChartsAndImages() : string
- generateMeta() : string
- generatePageDeclarations() : string
- Generate @page declarations.
- generateRow() : string
- Generate row.
- generateRowCellCss() : array<string|int, mixed>
- generateRowCellData() : string
- generateRowCellDataValue() : void
- generateRowCellDataValueRich() : void
- generateRowIncludeCharts() : string
- generateRowSpans() : string
- generateRowStart() : string
- Generate row start.
- generateRowWriteCell() : void
- generateSheetPrep() : array<string|int, mixed>
- generateSheetStarts() : array<string|int, mixed>
- generateSheetTags() : array<string|int, mixed>
- generateTableFooter() : string
- Generate table footer.
- generateTableHeader() : string
- Generate table header.
- generateTableTag() : void
- generateTableTagInline() : string
- inchesToMm() : float
- Convert inches to mm.
- mapBorderStyle() : string
- Map border style.
- mapHAlign() : string
- Map HAlign.
- mapVAlign() : string
- Map VAlign.
- writeChartInCell() : string
- Generate chart tag in cell.
- writeComment() : string
- Write a comment in the same format as LibreOffice.
- writeImageInCell() : string
- Generate image tag in cell.
Constants
BODY_LINE
public
mixed
BODY_LINE
= ' <body>' . PHP_EOL
BORDER_ARR
public
mixed
BORDER_ARR
= [PhpOfficePhpSpreadsheetStyleBorder::BORDER_NONE => 'none', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DASHDOT => '1px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DASHDOTDOT => '1px dotted', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DASHED => '1px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DOTTED => '1px dotted', PhpOfficePhpSpreadsheetStyleBorder::BORDER_DOUBLE => '3px double', PhpOfficePhpSpreadsheetStyleBorder::BORDER_HAIR => '1px solid', PhpOfficePhpSpreadsheetStyleBorder::BORDER_MEDIUM => '2px solid', PhpOfficePhpSpreadsheetStyleBorder::BORDER_MEDIUMDASHDOT => '2px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_MEDIUMDASHDOTDOT => '2px dotted', PhpOfficePhpSpreadsheetStyleBorder::BORDER_SLANTDASHDOT => '2px dashed', PhpOfficePhpSpreadsheetStyleBorder::BORDER_THICK => '3px solid']
CUSTOM_TO_META
private
mixed
CUSTOM_TO_META
= [PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_BOOLEAN => 'bool', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_DATE => 'date', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_FLOAT => 'float', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_INTEGER => 'int', PhpOfficePhpSpreadsheetDocumentProperties::PROPERTY_TYPE_STRING => 'string']
Properties
$embedImages
embed images, or link to images.
protected
bool
$embedImages
= false
$fileHandle
protected
resource
$fileHandle
$font
Font.
protected
string
$font
= 'freesans'
$includeCharts
Write charts that are defined in the workbook? Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object.
protected
bool
$includeCharts
= false
$isMPdf
protected
bool
$isMPdf
= true
$isPdf
Is the current writer creating PDF?
protected
bool
$isPdf
= false
$orientation
Orientation (Over-ride).
protected
string|null
$orientation
$paperSize
Paper size (Over-ride).
protected
int|null
$paperSize
$paperSizes
Paper Sizes xRef List.
protected
static array<string|int, mixed>
$paperSizes
= [
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LETTER => 'LETTER',
// (8.5 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER',
// (8.5 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_TABLOID => [792.0, 1224.0],
// (11 in. by 17 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LEDGER => [1224.0, 792.0],
// (17 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LEGAL => 'LEGAL',
// (8.5 in. by 14 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_STATEMENT => [396.0, 612.0],
// (5.5 in. by 8.5 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_EXECUTIVE => 'EXECUTIVE',
// (7.25 in. by 10.5 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A3 => 'A3',
// (297 mm by 420 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A4 => 'A4',
// (210 mm by 297 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A4_SMALL => 'A4',
// (210 mm by 297 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A5 => 'A5',
// (148 mm by 210 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_B4 => 'B4',
// (250 mm by 353 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_B5 => 'B5',
// (176 mm by 250 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_FOLIO => 'FOLIO',
// (8.5 in. by 13 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_QUARTO => [609.45, 779.53],
// (215 mm by 275 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_STANDARD_1 => [720.0, 1008.0],
// (10 in. by 14 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_STANDARD_2 => [792.0, 1224.0],
// (11 in. by 17 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_NOTE => 'LETTER',
// (8.5 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_NO9_ENVELOPE => [279.0, 639.0],
// (3.875 in. by 8.875 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_NO10_ENVELOPE => [297.0, 684.0],
// (4.125 in. by 9.5 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_NO11_ENVELOPE => [324.0, 747.0],
// (4.5 in. by 10.375 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_NO12_ENVELOPE => [342.0, 792.0],
// (4.75 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_NO14_ENVELOPE => [360.0, 828.0],
// (5 in. by 11.5 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_C => [1224.0, 1584.0],
// (17 in. by 22 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_D => [1584.0, 2448.0],
// (22 in. by 34 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_E => [2448.0, 3168.0],
// (34 in. by 44 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_DL_ENVELOPE => [311.81, 623.62],
// (110 mm by 220 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_C5_ENVELOPE => 'C5',
// (162 mm by 229 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_C3_ENVELOPE => 'C3',
// (324 mm by 458 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_C4_ENVELOPE => 'C4',
// (229 mm by 324 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_C6_ENVELOPE => 'C6',
// (114 mm by 162 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_C65_ENVELOPE => [323.15, 649.13],
// (114 mm by 229 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_B4_ENVELOPE => 'B4',
// (250 mm by 353 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_B5_ENVELOPE => 'B5',
// (176 mm by 250 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_B6_ENVELOPE => [498.9, 354.33],
// (176 mm by 125 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_ITALY_ENVELOPE => [311.81, 651.97],
// (110 mm by 230 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_MONARCH_ENVELOPE => [279.0, 540.0],
// (3.875 in. by 7.5 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_6_3_4_ENVELOPE => [261.0, 468.0],
// (3.625 in. by 6.5 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_US_STANDARD_FANFOLD => [1071.0, 792.0],
// (14.875 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD => [612.0, 864.0],
// (8.5 in. by 12 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD => 'FOLIO',
// (8.5 in. by 13 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_ISO_B4 => 'B4',
// (250 mm by 353 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD => [566.9299999999999, 419.53],
// (200 mm by 148 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_STANDARD_PAPER_1 => [648.0, 792.0],
// (9 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_STANDARD_PAPER_2 => [720.0, 792.0],
// (10 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_STANDARD_PAPER_3 => [1080.0, 792.0],
// (15 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_INVITE_ENVELOPE => [623.62, 623.62],
// (220 mm by 220 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LETTER_EXTRA_PAPER => [667.8, 864.0],
// (9.275 in. by 12 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER => [667.8, 1080.0],
// (9.275 in. by 15 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER => [841.6799999999999, 1296.0],
// (11.69 in. by 18 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A4_EXTRA_PAPER => [668.98, 912.76],
// (236 mm by 322 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER => [595.8, 792.0],
// (8.275 in. by 11 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER => 'A4',
// (210 mm by 297 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER => [667.8, 864.0],
// (9.275 in. by 12 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER => [643.46, 1009.13],
// (227 mm by 356 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER => [864.5700000000001, 1380.47],
// (305 mm by 487 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_LETTER_PLUS_PAPER => [612.0, 913.6799999999999],
// (8.5 in. by 12.69 in.)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A4_PLUS_PAPER => [595.28, 935.4299999999999],
// (210 mm by 330 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER => 'A5',
// (148 mm by 210 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER => [515.91, 728.5],
// (182 mm by 257 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A3_EXTRA_PAPER => [912.76, 1261.42],
// (322 mm by 445 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A5_EXTRA_PAPER => [493.23, 666.14],
// (174 mm by 235 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER => [569.76, 782.36],
// (201 mm by 276 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A2_PAPER => 'A2',
// (420 mm by 594 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER => 'A3',
// (297 mm by 420 mm)
PhpOfficePhpSpreadsheetWorksheetPageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER => [912.76, 1261.42],
]
$preCalculateFormulas
Pre-calculate formulas Forces PhpSpreadsheet to 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.
protected
bool
$preCalculateFormulas
= true
$spreadsheet
Spreadsheet object.
protected
Spreadsheet
$spreadsheet
$tempDir
Temporary storage directory.
protected
string
$tempDir
= ''
$columnWidths
Array of column widths in points.
private
array<string|int, mixed>
$columnWidths
$cssStyles
Array of CSS styles.
private
array<string|int, mixed>
$cssStyles
$defaultFont
Default font.
private
Font
$defaultFont
$diskCachingDirectory
Disk caching directory.
private
string
$diskCachingDirectory
= './'
$editHtmlCallback
Callback for editing generated html.
private
null|callable
$editHtmlCallback
$generateSheetNavigationBlock
Generate the Navigation block.
private
bool
$generateSheetNavigationBlock
= true
$imagesRoot
Images root.
private
string
$imagesRoot
= ''
$isBaseCell
Excel cells that are upper-left corner in a cell merge.
private
array<string|int, mixed>
$isBaseCell
= []
$isSpannedCell
Excel cells that should not be written as HTML cells.
private
array<string|int, mixed>
$isSpannedCell
= []
$isSpannedRow
Excel rows that should not be written as HTML rows.
private
array<string|int, mixed>
$isSpannedRow
= []
$sheetIndex
Sheet index to write.
private
null|int
$sheetIndex
= 0
$shouldCloseFile
private
bool
$shouldCloseFile
$spansAreCalculated
Flag whether spans have been calculated.
private
bool
$spansAreCalculated
= false
$useDiskCaching
Use disk caching where possible?
private
bool
$useDiskCaching
= false
$useEmbeddedCSS
Use embedded CSS?
private
bool
$useEmbeddedCSS
= true
$useInlineCss
Use inline CSS?
private
bool
$useInlineCss
= false
Methods
__construct()
Create a new HTML.
public
__construct(Spreadsheet $spreadsheet) : mixed
Parameters
- $spreadsheet : Spreadsheet
Return values
mixed —buildCSS()
Build CSS styles.
public
buildCSS([bool $generateSurroundingHTML = true ]) : array<string|int, mixed>
Parameters
- $generateSurroundingHTML : bool = true
-
Generate surrounding HTML style? (html { })
Return values
array<string|int, mixed> —formatColor()
Add color to formatted string as inline style.
public
formatColor(string $value, string $format) : string
Parameters
- $value : string
-
Plain formatted value without color
- $format : string
-
Format code
Return values
string —generateHtmlAll()
Save Spreadsheet as html to variable.
public
generateHtmlAll() : string
Return values
string —generateHTMLFooter()
Generate HTML footer.
public
generateHTMLFooter() : string
Return values
string —generateHTMLHeader()
Generate HTML header.
public
generateHTMLHeader([bool $includeStyles = false ]) : string
Parameters
- $includeStyles : bool = false
-
Include styles?
Return values
string —generateNavigation()
Generate sheet tabs.
public
generateNavigation() : string
Return values
string —generateSheetData()
Generate sheet data.
public
generateSheetData() : string
Return values
string —generateStyles()
Generate CSS styles.
public
generateStyles([bool $generateSurroundingHTML = true ]) : string
Parameters
- $generateSurroundingHTML : bool = true
-
Generate surrounding HTML tags? (<style> and </style>)
Return values
string —getDiskCachingDirectory()
Get disk caching directory.
public
getDiskCachingDirectory() : string
Return values
string —getEmbedImages()
Get embed images.
public
getEmbedImages() : bool
Return values
bool —getFont()
Get Font.
public
getFont() : string
Return values
string —getGenerateSheetNavigationBlock()
Get sheet index.
public
getGenerateSheetNavigationBlock() : bool
Return values
bool —getImagesRoot()
Get images root.
public
getImagesRoot() : string
Return values
string —getIncludeCharts()
Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object.
public
getIncludeCharts() : bool
If false (the default) it will ignore any charts defined in the PhpSpreadsheet object.
Return values
bool —getOrientation()
public
getOrientation() : string|null
Return values
string|null —getPaperSize()
Get Paper Size.
public
getPaperSize() : int|null
Return values
int|null —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. This is faster for saving in PhpSpreadsheet, but slower when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself.
public
getPreCalculateFormulas() : bool
Return values
bool —getSheetIndex()
Get sheet index.
public
getSheetIndex() : int|null
Return values
int|null —getTempDir()
Get temporary storage directory.
public
getTempDir() : string
Return values
string —getUseDiskCaching()
Get use disk caching where possible?
public
getUseDiskCaching() : bool
Return values
bool —getUseEmbeddedCSS()
Get use embedded CSS?
public
getUseEmbeddedCSS() : bool
Tags
Return values
bool —getUseInlineCss()
Get use inline CSS?
public
getUseInlineCss() : bool
Return values
bool —openFileHandle()
Open file handle.
public
openFileHandle(resource|string $filename) : void
Parameters
- $filename : resource|string
Return values
void —save()
Save Spreadsheet to file.
public
save(string $filename, int $flags) : void
Parameters
- $filename : string
-
Name of the file to save as
- $flags : int
Return values
void —setEditHtmlCallback()
Set a callback to edit the entire HTML.
public
setEditHtmlCallback(callable|null $callback) : void
The callback must accept the HTML as string as first parameter, and it must return the edited HTML as string.
Parameters
- $callback : callable|null
Return values
void —setEmbedImages()
Set embed images.
public
setEmbedImages(bool $embedImages) : $this
Parameters
- $embedImages : bool
Return values
$this —setFont()
Set font. Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'.
public
setFont(string $fontName) : $this
Parameters
- $fontName : string
Return values
$this —setGenerateSheetNavigationBlock()
Set sheet index.
public
setGenerateSheetNavigationBlock(bool $generateSheetNavigationBlock) : $this
Parameters
- $generateSheetNavigationBlock : bool
-
Flag indicating whether the sheet navigation block should be generated or not
Return values
$this —setImagesRoot()
Set images root.
public
setImagesRoot(string $imagesRoot) : $this
Parameters
- $imagesRoot : string
Return values
$this —setIncludeCharts()
Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.
public
setIncludeCharts(mixed $includeCharts) : IWriter
Set to false (the default) to ignore charts.
Parameters
- $includeCharts : mixed
Return values
IWriter —setOrientation()
Set Orientation.
public
setOrientation(string $orientation) : self
Parameters
- $orientation : string
-
Page orientation see PageSetup::ORIENTATION_*
Return values
self —setPaperSize()
Set Paper Size.
public
setPaperSize(int $paperSize) : self
Parameters
- $paperSize : int
-
Paper size see PageSetup::PAPERSIZE_*
Return values
self —setPreCalculateFormulas()
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.
public
setPreCalculateFormulas(mixed $precalculateFormulas) : IWriter
Parameters
- $precalculateFormulas : mixed
-
Pre-Calculate Formulas?
Return values
IWriter —setSheetIndex()
Set sheet index.
public
setSheetIndex(int $sheetIndex) : $this
Parameters
- $sheetIndex : int
-
Sheet index
Return values
$this —setTempDir()
Set temporary storage directory.
public
setTempDir(string $temporaryDirectory) : self
Parameters
- $temporaryDirectory : string
-
Temporary storage directory
Return values
self —setUseDiskCaching()
Set use disk caching where possible?
public
setUseDiskCaching(mixed $useDiskCache[, mixed $cacheDirectory = null ]) : IWriter
Parameters
- $useDiskCache : mixed
- $cacheDirectory : mixed = null
-
Disk caching directory
Return values
IWriter —setUseEmbeddedCSS()
Set use embedded CSS?
public
setUseEmbeddedCSS(bool $useEmbeddedCSS) : $this
Parameters
- $useEmbeddedCSS : bool
Tags
Return values
$this —setUseInlineCss()
Set use inline CSS?
public
setUseInlineCss(bool $useInlineCss) : $this
Parameters
- $useInlineCss : bool
Return values
$this —winFileToUrl()
Convert Windows file name to file protocol URL.
public
static winFileToUrl(string $filename[, bool $mpdf = false ]) : string
Parameters
- $filename : string
-
file name on local system
- $mpdf : bool = false
Return values
string —writeAllSheets()
Write all sheets (resets sheetIndex to NULL).
public
writeAllSheets() : $this
Return values
$this —createExternalWriterInstance()
Gets the implementation of external PDF library that should be used.
protected
createExternalWriterInstance(array<string|int, mixed> $config) : Mpdf
Parameters
- $config : array<string|int, mixed>
-
Configuration array
Return values
Mpdf —implementation
maybeCloseFileHandle()
Close file handle only if we opened it ourselves.
protected
maybeCloseFileHandle() : void
Return values
void —prepareForSave()
Save Spreadsheet to PDF file, pre-save.
protected
prepareForSave(string $filename) : resource
Parameters
- $filename : string
-
Name of the file to save as
Return values
resource —processFlags()
protected
processFlags(int $flags) : void
Parameters
- $flags : int
Return values
void —restoreStateAfterSave()
Save PhpSpreadsheet to PDF file, post-save.
protected
restoreStateAfterSave() : void
Return values
void —assembleCSS()
Takes array where of CSS properties / values and converts to CSS string.
private
assembleCSS([array<string|int, mixed> $values = [] ]) : string
Parameters
- $values : array<string|int, mixed> = []
Return values
string —buildCssPerSheet()
private
buildCssPerSheet(Worksheet $sheet, array<string|int, mixed> &$css) : void
Parameters
- $sheet : Worksheet
- $css : array<string|int, mixed>
Return values
void —buildCssRowHeights()
private
buildCssRowHeights(Worksheet $sheet, array<string|int, mixed> &$css, int $sheetIndex) : void
Parameters
- $sheet : Worksheet
- $css : array<string|int, mixed>
- $sheetIndex : int
Return values
void —calculateSpans()
Calculate information about HTML colspan and rowspan which is not always the same as Excel's.
private
calculateSpans() : void
Return values
void —calculateSpansOmitRows()
private
calculateSpansOmitRows(Worksheet $sheet, int $sheetIndex, array<string|int, mixed> $candidateSpannedRow) : void
Parameters
- $sheet : Worksheet
- $sheetIndex : int
- $candidateSpannedRow : array<string|int, mixed>
Return values
void —createCSSStyle()
Create CSS style.
private
createCSSStyle(Style $style) : array<string|int, mixed>
Parameters
- $style : Style
Return values
array<string|int, mixed> —createCSSStyleAlignment()
Create CSS style.
private
createCSSStyleAlignment(Alignment $alignment) : array<string|int, mixed>
Parameters
- $alignment : Alignment
Return values
array<string|int, mixed> —createCSSStyleBorder()
Create CSS style.
private
createCSSStyleBorder(Border $border) : string
Parameters
- $border : Border
-
Border
Return values
string —createCSSStyleBorders()
Create CSS style.
private
createCSSStyleBorders(Borders $borders) : array<string|int, mixed>
Parameters
- $borders : Borders
-
Borders
Return values
array<string|int, mixed> —createCSSStyleFill()
Create CSS style (Fill).
private
createCSSStyleFill(Fill $fill) : array<string|int, mixed>
Parameters
- $fill : Fill
-
Fill
Return values
array<string|int, mixed> —createCSSStyleFont()
Create CSS style.
private
createCSSStyleFont(Font $font) : array<string|int, mixed>
Parameters
- $font : Font
Return values
array<string|int, mixed> —extendRowsForCharts()
Extend Row if chart is placed after nominal end of row.
private
extendRowsForCharts(Worksheet $worksheet, int $row) : array<string|int, mixed>
This code should be exercised by sample: Chart/32_Chart_read_write_PDF.php.
Parameters
- $worksheet : Worksheet
- $row : int
-
Row to check for charts
Return values
array<string|int, mixed> —extendRowsForChartsAndImages()
private
extendRowsForChartsAndImages(Worksheet $worksheet, int $row) : string
Parameters
- $worksheet : Worksheet
- $row : int
Return values
string —generateMeta()
private
static generateMeta(string|null $val, string $desc) : string
Parameters
- $val : string|null
- $desc : string
Return values
string —generatePageDeclarations()
Generate @page declarations.
private
generatePageDeclarations(bool $generateSurroundingHTML) : string
Parameters
- $generateSurroundingHTML : bool
Return values
string —generateRow()
Generate row.
private
generateRow(Worksheet $worksheet, array<string|int, mixed> $values, int $row, string $cellType) : string
Parameters
- $worksheet : Worksheet
- $values : array<string|int, mixed>
-
Array containing cells in a row
- $row : int
-
Row number (0-based)
- $cellType : string
-
eg: 'td'
Return values
string —generateRowCellCss()
private
generateRowCellCss(Worksheet $worksheet, string $cellAddress, int $row, int $columnNumber) : array<string|int, mixed>
Parameters
- $worksheet : Worksheet
- $cellAddress : string
- $row : int
- $columnNumber : int
Return values
array<string|int, mixed> —generateRowCellData()
private
generateRowCellData(Worksheet $worksheet, null|Cell|string $cell, array<string|int, mixed>|string &$cssClass, string $cellType) : string
Parameters
- $worksheet : Worksheet
- $cell : null|Cell|string
- $cssClass : array<string|int, mixed>|string
- $cellType : string
Return values
string —generateRowCellDataValue()
private
generateRowCellDataValue(Worksheet $worksheet, Cell $cell, string &$cellData) : void
Parameters
Return values
void —generateRowCellDataValueRich()
private
generateRowCellDataValueRich(Cell $cell, string &$cellData) : void
Parameters
- $cell : Cell
- $cellData : string
Return values
void —generateRowIncludeCharts()
private
generateRowIncludeCharts(Worksheet $worksheet, string $coordinate) : string
Parameters
- $worksheet : Worksheet
- $coordinate : string
Return values
string —generateRowSpans()
private
generateRowSpans(string $html, int $rowSpan, int $colSpan) : string
Parameters
- $html : string
- $rowSpan : int
- $colSpan : int
Return values
string —generateRowStart()
Generate row start.
private
generateRowStart(Worksheet $worksheet, int $sheetIndex, int $row) : string
Parameters
- $worksheet : Worksheet
- $sheetIndex : int
-
Sheet index (0-based)
- $row : int
-
row number
Return values
string —generateRowWriteCell()
private
generateRowWriteCell(string &$html, Worksheet $worksheet, string $coordinate, string $cellType, string $cellData, int $colSpan, int $rowSpan, array<string|int, mixed>|string $cssClass, int $colNum, int $sheetIndex, int $row) : void
Parameters
- $html : string
- $worksheet : Worksheet
- $coordinate : string
- $cellType : string
- $cellData : string
- $colSpan : int
- $rowSpan : int
- $cssClass : array<string|int, mixed>|string
- $colNum : int
- $sheetIndex : int
- $row : int
Return values
void —generateSheetPrep()
private
generateSheetPrep() : array<string|int, mixed>
Return values
array<string|int, mixed> —generateSheetStarts()
private
generateSheetStarts(Worksheet $sheet, int $rowMin) : array<string|int, mixed>
Parameters
- $sheet : Worksheet
- $rowMin : int
Return values
array<string|int, mixed> —generateSheetTags()
private
generateSheetTags(int $row, int $theadStart, int $theadEnd, int $tbodyStart) : array<string|int, mixed>
Parameters
- $row : int
- $theadStart : int
- $theadEnd : int
- $tbodyStart : int
Return values
array<string|int, mixed> —generateTableFooter()
Generate table footer.
private
generateTableFooter() : string
Return values
string —generateTableHeader()
Generate table header.
private
generateTableHeader(Worksheet $worksheet[, bool $showid = true ]) : string
Parameters
- $worksheet : Worksheet
-
The worksheet for the table we are writing
- $showid : bool = true
-
whether or not to add id to table tag
Return values
string —generateTableTag()
private
generateTableTag(Worksheet $worksheet, string $id, string &$html, int $sheetIndex) : void
Parameters
- $worksheet : Worksheet
- $id : string
- $html : string
- $sheetIndex : int
Return values
void —generateTableTagInline()
private
generateTableTagInline(Worksheet $worksheet, string $id) : string
Parameters
- $worksheet : Worksheet
- $id : string
Return values
string —inchesToMm()
Convert inches to mm.
private
inchesToMm(float $inches) : float
Parameters
- $inches : float
Return values
float —mapBorderStyle()
Map border style.
private
mapBorderStyle(int|string $borderStyle) : string
Parameters
- $borderStyle : int|string
-
Sheet index
Return values
string —mapHAlign()
Map HAlign.
private
mapHAlign(string $hAlign) : string
Parameters
- $hAlign : string
-
Horizontal alignment
Return values
string —mapVAlign()
Map VAlign.
private
mapVAlign(string $vAlign) : string
Parameters
- $vAlign : string
-
Vertical alignment
Return values
string —writeChartInCell()
Generate chart tag in cell.
private
writeChartInCell(Worksheet $worksheet, string $coordinates) : string
This code should be exercised by sample: Chart/32_Chart_read_write_PDF.php.
Parameters
- $worksheet : Worksheet
- $coordinates : string
Return values
string —writeComment()
Write a comment in the same format as LibreOffice.
private
writeComment(Worksheet $worksheet, string $coordinate) : string
Parameters
- $worksheet : Worksheet
- $coordinate : string
Tags
Return values
string —writeImageInCell()
Generate image tag in cell.
private
writeImageInCell(Worksheet $worksheet, string $coordinates) : string
Parameters
- $worksheet : Worksheet
-
\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
- $coordinates : string
-
Cell coordinates