Mpdf
extends Pdf
in package
Table of Contents
Constants
- BODY_LINE = ' <body>' . PHP_EOL
- BORDER_ARR = [\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE => self::BORDER_NONE, \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT => '1px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT => '1px dotted', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED => '1px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED => '1px dotted', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE => '3px double', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR => '1px solid', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM => '2px solid', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT => '2px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT => '2px dotted', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT => '2px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK => '3px solid']
- BORDER_NONE = 'none'
- COMMENT_HTML_TAGS_PLAINTEXT = true
- Migration aid to tell if html tags will be treated as plaintext in comments.
- SIMULATED_BODY_START = '<!-- simulated body start -->'
- BODY_TAG = '<body>'
- CUSTOM_TO_META = [\PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN => 'bool', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE => 'date', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_FLOAT => 'float', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_INTEGER => 'int', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_STRING => 'string']
- DEFAULT_CELL_WIDTH_PIXELS = 56
- DEFAULT_CELL_WIDTH_POINTS = 42
Properties
- $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
- Is the current writer creating mPDF?
- $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>|null
- 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.
- $sheetCharts : array<string|int, Chart>
- $sheetDrawings : array<string|int, BaseDrawing>
- $sheetIndex : int|null
- Sheet index to write.
- $shouldCloseFile : bool
- $spansAreCalculated : bool
- Flag whether spans have been calculated.
- $useDiskCaching : bool
- Use disk caching where possible?
- $useInlineCss : bool
- Use inline CSS?
Methods
- __construct() : mixed
- Create a new PDF Writer instance.
- 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
- Get Orientation.
- 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?
- 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() : $this
- 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() : $this
- 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() : $this
- Set use disk caching where possible?
- 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.
- adjustRendererPositions() : void
- 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.
- extendRowsAndColumns() : void
- generateMeta() : string
- generatePageDeclarations() : string
- Generate @page declarations.
- generateRow() : string
- Generate row.
- generateRowCellCss() : array<string|int, mixed>
- generateRowCellData() : string
- generateRowCellDataValue() : void
- generateRowCellDataValueRich() : string
- generateRowIncludeCharts() : string
- generateRowSpans() : string
- generateRowStart() : string
- Generate row start.
- generateRowWriteCell() : void
- generateSheetPrep() : array<string|int, Worksheet>
- 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.
- shouldGenerateColumn() : bool
- shouldGenerateRow() : bool
- 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
= [\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE => self::BORDER_NONE, \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT => '1px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT => '1px dotted', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED => '1px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED => '1px dotted', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE => '3px double', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR => '1px solid', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM => '2px solid', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT => '2px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT => '2px dotted', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT => '2px dashed', \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK => '3px solid']
BORDER_NONE
public
mixed
BORDER_NONE
= 'none'
COMMENT_HTML_TAGS_PLAINTEXT
Migration aid to tell if html tags will be treated as plaintext in comments.
public
mixed
COMMENT_HTML_TAGS_PLAINTEXT
= true
if ( defined( \PhpOffice\PhpSpreadsheet\Writer\Html::class . '::COMMENT_HTML_TAGS_PLAINTEXT' ) ) { new logic with styling in TextRun elements } else { old logic with styling via Html tags }.
SIMULATED_BODY_START
public
mixed
SIMULATED_BODY_START
= '<!-- simulated body start -->'
BODY_TAG
private
mixed
BODY_TAG
= '<body>'
CUSTOM_TO_META
private
mixed
CUSTOM_TO_META
= [\PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN => 'bool', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE => 'date', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_FLOAT => 'float', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_INTEGER => 'int', \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_STRING => 'string']
DEFAULT_CELL_WIDTH_PIXELS
private
mixed
DEFAULT_CELL_WIDTH_PIXELS
= 56
DEFAULT_CELL_WIDTH_POINTS
private
mixed
DEFAULT_CELL_WIDTH_POINTS
= 42
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
Is the current writer creating mPDF?
protected
bool
$isMPdf
= true
Tags
$isPdf
Is the current writer creating PDF?
protected
bool
$isPdf
= false
$orientation
Orientation (Over-ride).
protected
string|null
$orientation
= null
$paperSize
Paper size (Over-ride).
protected
int|null
$paperSize
= null
$paperSizes
Paper Sizes xRef List.
protected
static array<string|int, mixed>
$paperSizes
= [
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER => 'LETTER',
// (8.5 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER',
// (8.5 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID => [792.0, 1224.0],
// (11 in. by 17 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEDGER => [1224.0, 792.0],
// (17 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL => 'LEGAL',
// (8.5 in. by 14 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STATEMENT => [396.0, 612.0],
// (5.5 in. by 8.5 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_EXECUTIVE => 'EXECUTIVE',
// (7.25 in. by 10.5 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3 => 'A3',
// (297 mm by 420 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4 => 'A4',
// (210 mm by 297 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_SMALL => 'A4',
// (210 mm by 297 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5 => 'A5',
// (148 mm by 210 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4 => 'B4',
// (250 mm by 353 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5 => 'B5',
// (176 mm by 250 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_FOLIO => 'FOLIO',
// (8.5 in. by 13 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_QUARTO => [609.45, 779.53],
// (215 mm by 275 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_1 => [720.0, 1008.0],
// (10 in. by 14 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_2 => [792.0, 1224.0],
// (11 in. by 17 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NOTE => 'LETTER',
// (8.5 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO9_ENVELOPE => [279.0, 639.0],
// (3.875 in. by 8.875 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO10_ENVELOPE => [297.0, 684.0],
// (4.125 in. by 9.5 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO11_ENVELOPE => [324.0, 747.0],
// (4.5 in. by 10.375 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO12_ENVELOPE => [342.0, 792.0],
// (4.75 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO14_ENVELOPE => [360.0, 828.0],
// (5 in. by 11.5 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C => [1224.0, 1584.0],
// (17 in. by 22 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_D => [1584.0, 2448.0],
// (22 in. by 34 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_E => [2448.0, 3168.0],
// (34 in. by 44 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_DL_ENVELOPE => [311.81, 623.62],
// (110 mm by 220 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C5_ENVELOPE => 'C5',
// (162 mm by 229 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C3_ENVELOPE => 'C3',
// (324 mm by 458 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C4_ENVELOPE => 'C4',
// (229 mm by 324 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C6_ENVELOPE => 'C6',
// (114 mm by 162 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C65_ENVELOPE => [323.15, 649.13],
// (114 mm by 229 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4_ENVELOPE => 'B4',
// (250 mm by 353 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5_ENVELOPE => 'B5',
// (176 mm by 250 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B6_ENVELOPE => [498.9, 354.33],
// (176 mm by 125 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ITALY_ENVELOPE => [311.81, 651.97],
// (110 mm by 230 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_MONARCH_ENVELOPE => [279.0, 540.0],
// (3.875 in. by 7.5 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_6_3_4_ENVELOPE => [261.0, 468.0],
// (3.625 in. by 6.5 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_US_STANDARD_FANFOLD => [1071.0, 792.0],
// (14.875 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD => [612.0, 864.0],
// (8.5 in. by 12 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD => 'FOLIO',
// (8.5 in. by 13 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B4 => 'B4',
// (250 mm by 353 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD => [566.9299999999999, 419.53],
// (200 mm by 148 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_1 => [648.0, 792.0],
// (9 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_2 => [720.0, 792.0],
// (10 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_3 => [1080.0, 792.0],
// (15 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_INVITE_ENVELOPE => [623.62, 623.62],
// (220 mm by 220 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER => [667.8, 864.0],
// (9.275 in. by 12 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER => [667.8, 1080.0],
// (9.275 in. by 15 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER => [841.6799999999999, 1296.0],
// (11.69 in. by 18 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_EXTRA_PAPER => [668.98, 912.76],
// (236 mm by 322 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER => [595.8, 792.0],
// (8.275 in. by 11 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER => 'A4',
// (210 mm by 297 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER => [667.8, 864.0],
// (9.275 in. by 12 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER => [643.46, 1009.13],
// (227 mm by 356 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER => [864.5700000000001, 1380.47],
// (305 mm by 487 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_PLUS_PAPER => [612.0, 913.6799999999999],
// (8.5 in. by 12.69 in.)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_PLUS_PAPER => [595.28, 935.4299999999999],
// (210 mm by 330 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER => 'A5',
// (148 mm by 210 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER => [515.91, 728.5],
// (182 mm by 257 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_EXTRA_PAPER => [912.76, 1261.42],
// (322 mm by 445 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_EXTRA_PAPER => [493.23, 666.14],
// (174 mm by 235 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER => [569.76, 782.36],
// (201 mm by 276 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A2_PAPER => 'A2',
// (420 mm by 594 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER => 'A3',
// (297 mm by 420 mm)
\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::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>|null
$cssStyles
= null
$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
= []
$sheetCharts
private
array<string|int, Chart>
$sheetCharts
$sheetDrawings
private
array<string|int, BaseDrawing>
$sheetDrawings
$sheetIndex
Sheet index to write.
private
int|null
$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
$useInlineCss
Use inline CSS?
private
bool
$useInlineCss
= false
Methods
__construct()
Create a new PDF Writer instance.
public
__construct(Spreadsheet $spreadsheet) : mixed
Parameters
- $spreadsheet : Spreadsheet
-
Spreadsheet object
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
stringgenerateHtmlAll()
Save Spreadsheet as html to variable.
public
generateHtmlAll() : string
Return values
stringgenerateHTMLFooter()
Generate HTML footer.
public
generateHTMLFooter() : string
Return values
stringgenerateHTMLHeader()
Generate HTML header.
public
generateHTMLHeader([bool $includeStyles = false ]) : string
Parameters
- $includeStyles : bool = false
-
Include styles?
Return values
stringgenerateNavigation()
Generate sheet tabs.
public
generateNavigation() : string
Return values
stringgenerateSheetData()
Generate sheet data.
public
generateSheetData() : string
Return values
stringgenerateStyles()
Generate CSS styles.
public
generateStyles([bool $generateSurroundingHTML = true ]) : string
Parameters
- $generateSurroundingHTML : bool = true
-
Generate surrounding HTML tags? (<style> and </style>)
Return values
stringgetDiskCachingDirectory()
Get disk caching directory.
public
getDiskCachingDirectory() : string
Return values
stringgetEmbedImages()
Get embed images.
public
getEmbedImages() : bool
Return values
boolgetFont()
Get Font.
public
getFont() : string
Return values
stringgetGenerateSheetNavigationBlock()
Get sheet index.
public
getGenerateSheetNavigationBlock() : bool
Return values
boolgetImagesRoot()
Get images root.
public
getImagesRoot() : string
Return values
stringgetIncludeCharts()
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
boolgetOrientation()
Get Orientation.
public
getOrientation() : string|null
Return values
string|nullgetPaperSize()
Get Paper Size.
public
getPaperSize() : int|null
Return values
int|nullgetPreCalculateFormulas()
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
boolgetSheetIndex()
Get sheet index.
public
getSheetIndex() : int|null
Return values
int|nullgetTempDir()
Get temporary storage directory.
public
getTempDir() : string
Return values
stringgetUseDiskCaching()
Get use disk caching where possible?
public
getUseDiskCaching() : bool
Return values
boolgetUseInlineCss()
Get use inline CSS?
public
getUseInlineCss() : bool
Return values
boolopenFileHandle()
Open file handle.
public
openFileHandle(resource|string $filename) : void
Parameters
- $filename : resource|string
save()
Save Spreadsheet to file.
public
save(string $filename[, int $flags = 0 ]) : void
Parameters
- $filename : string
-
Name of the file to save as
- $flags : int = 0
-
Flags that can change the behaviour of the Writer: self::SAVE_WITH_CHARTS Save any charts that are defined (if the Writer supports Charts) self::DISABLE_PRECALCULATE_FORMULAE Don't Precalculate formulae before saving the file
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
setEmbedImages()
Set embed images.
public
setEmbedImages(bool $embedImages) : $this
Parameters
- $embedImages : bool
Return values
$thissetFont()
Set font. Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'.
public
setFont(string $fontName) : $this
Parameters
- $fontName : string
Return values
$thissetGenerateSheetNavigationBlock()
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
$thissetImagesRoot()
Set images root.
public
setImagesRoot(string $imagesRoot) : $this
Parameters
- $imagesRoot : string
Return values
$thissetIncludeCharts()
Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.
public
setIncludeCharts(bool $includeCharts) : $this
Set to false (the default) to ignore charts.
Parameters
- $includeCharts : bool
Return values
$thissetOrientation()
Set Orientation.
public
setOrientation(string $orientation) : self
Parameters
- $orientation : string
-
Page orientation see PageSetup::ORIENTATION_*
Return values
selfsetPaperSize()
Set Paper Size.
public
setPaperSize(int $paperSize) : self
Parameters
- $paperSize : int
-
Paper size see PageSetup::PAPERSIZE_*
Return values
selfsetPreCalculateFormulas()
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(bool $precalculateFormulas) : $this
Parameters
- $precalculateFormulas : bool
-
Pre-Calculate Formulas?
Return values
$thissetSheetIndex()
Set sheet index.
public
setSheetIndex(int $sheetIndex) : $this
Parameters
- $sheetIndex : int
-
Sheet index
Return values
$thissetTempDir()
Set temporary storage directory.
public
setTempDir(string $temporaryDirectory) : self
Parameters
- $temporaryDirectory : string
-
Temporary storage directory
Return values
selfsetUseDiskCaching()
Set use disk caching where possible?
public
setUseDiskCaching(bool $useDiskCache[, string|null $cacheDirectory = null ]) : $this
Parameters
- $useDiskCache : bool
- $cacheDirectory : string|null = null
-
Disk caching directory
Return values
$thissetUseInlineCss()
Set use inline CSS?
public
setUseInlineCss(bool $useInlineCss) : $this
Parameters
- $useInlineCss : bool
Return values
$thiswinFileToUrl()
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
stringwriteAllSheets()
Write all sheets (resets sheetIndex to NULL).
public
writeAllSheets() : $this
Return values
$thiscreateExternalWriterInstance()
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
prepareForSave()
Save Spreadsheet to PDF file, pre-save.
protected
prepareForSave(resource|string $filename) : resource
Parameters
- $filename : resource|string
-
Name of the file to save as
Return values
resourceprocessFlags()
protected
processFlags(int $flags) : void
Parameters
- $flags : int
restoreStateAfterSave()
Save PhpSpreadsheet to PDF file, post-save.
protected
restoreStateAfterSave() : void
adjustRendererPositions()
private
adjustRendererPositions(Chart $chart, Worksheet $sheet) : void
Parameters
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
stringbuildCssPerSheet()
private
buildCssPerSheet(Worksheet $sheet, array<string|int, mixed> &$css) : void
Parameters
- $sheet : Worksheet
- $css : array<string|int, mixed>
buildCssRowHeights()
private
buildCssRowHeights(Worksheet $sheet, array<string|int, mixed> &$css, int $sheetIndex) : void
Parameters
- $sheet : Worksheet
- $css : array<string|int, mixed>
- $sheetIndex : int
calculateSpans()
Calculate information about HTML colspan and rowspan which is not always the same as Excel's.
private
calculateSpans() : void
calculateSpansOmitRows()
private
calculateSpansOmitRows(Worksheet $sheet, int $sheetIndex, array<string|int, mixed> $candidateSpannedRow) : void
Parameters
- $sheet : Worksheet
- $sheetIndex : int
- $candidateSpannedRow : array<string|int, mixed>
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
stringcreateCSSStyleBorders()
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>extendRowsAndColumns()
private
extendRowsAndColumns(Worksheet $worksheet, int &$colMax, int &$rowMax) : void
Parameters
- $worksheet : Worksheet
- $colMax : int
- $rowMax : int
generateMeta()
private
static generateMeta(string|null $val, string $desc) : string
Parameters
- $val : string|null
- $desc : string
Return values
stringgeneratePageDeclarations()
Generate @page declarations.
private
generatePageDeclarations(bool $generateSurroundingHTML) : string
Parameters
- $generateSurroundingHTML : bool
Return values
stringgenerateRow()
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
stringgenerateRowCellCss()
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
Parameters
Return values
stringgenerateRowCellDataValue()
private
generateRowCellDataValue(Worksheet $worksheet, Cell $cell, string &$cellData) : void
Parameters
generateRowCellDataValueRich()
private
generateRowCellDataValueRich(RichText $richText) : string
Parameters
- $richText : RichText
Return values
stringgenerateRowIncludeCharts()
private
generateRowIncludeCharts(Worksheet $worksheet, string $coordinate) : string
Parameters
- $worksheet : Worksheet
- $coordinate : string
Return values
stringgenerateRowSpans()
private
generateRowSpans(string $html, int $rowSpan, int $colSpan) : string
Parameters
- $html : string
- $rowSpan : int
- $colSpan : int
Return values
stringgenerateRowStart()
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
stringgenerateRowWriteCell()
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
generateSheetPrep()
private
generateSheetPrep() : array<string|int, Worksheet>
Return values
array<string|int, Worksheet>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
stringgenerateTableHeader()
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
stringgenerateTableTag()
private
generateTableTag(Worksheet $worksheet, string $id, string &$html, int $sheetIndex) : void
Parameters
- $worksheet : Worksheet
- $id : string
- $html : string
- $sheetIndex : int
generateTableTagInline()
private
generateTableTagInline(Worksheet $worksheet, string $id) : string
Parameters
- $worksheet : Worksheet
- $id : string
Return values
stringinchesToMm()
Convert inches to mm.
private
inchesToMm(float $inches) : float
Parameters
- $inches : float
Return values
floatmapBorderStyle()
Map border style.
private
mapBorderStyle(int|string $borderStyle) : string
Parameters
- $borderStyle : int|string
-
Sheet index
Return values
stringmapHAlign()
Map HAlign.
private
mapHAlign(string $hAlign) : string
Parameters
- $hAlign : string
-
Horizontal alignment
Return values
stringmapVAlign()
Map VAlign.
private
mapVAlign(string $vAlign) : string
Parameters
- $vAlign : string
-
Vertical alignment
Return values
stringshouldGenerateColumn()
private
shouldGenerateColumn(Worksheet $sheet, string $colStr) : bool
Parameters
- $sheet : Worksheet
- $colStr : string
Return values
boolshouldGenerateRow()
private
shouldGenerateRow(Worksheet $sheet, int $row) : bool
Parameters
- $sheet : Worksheet
- $row : int
Return values
boolwriteChartInCell()
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
stringwriteComment()
Write a comment in the same format as LibreOffice.
private
writeComment(Worksheet $worksheet, string $coordinate) : string
Parameters
- $worksheet : Worksheet
- $coordinate : string
Tags
Return values
stringwriteImageInCell()
Generate image tag in cell.
private
writeImageInCell(string $coordinates) : string
Parameters
- $coordinates : string
-
Cell coordinates