\PhpOffice\PhpSpreadsheet\Writer\PdfMpdf

Summary

Methods
Properties
Constants
__construct()
getFont()
setFont()
getPaperSize()
setPaperSize()
getOrientation()
setOrientation()
getTempDir()
setTempDir()
save()
getSheetIndex()
setSheetIndex()
getGenerateSheetNavigationBlock()
setGenerateSheetNavigationBlock()
writeAllSheets()
generateHTMLHeader()
generateSheetData()
generateNavigation()
generateStyles()
buildCSS()
generateHTMLFooter()
getImagesRoot()
setImagesRoot()
getEmbedImages()
setEmbedImages()
getUseInlineCss()
setUseInlineCss()
formatColor()
getIncludeCharts()
setIncludeCharts()
getPreCalculateFormulas()
setPreCalculateFormulas()
getUseDiskCaching()
setUseDiskCaching()
getDiskCachingDirectory()
No public properties found
No constants found
prepareForSave()
restoreStateAfterSave()
createExternalWriterInstance()
$tempDir
$font
$orientation
$paperSize
$paperSizes
$spreadsheet
$isPdf
$includeCharts
$preCalculateFormulas
N/A
mapVAlign()
mapHAlign()
mapBorderStyle()
extendRowsForChartsAndImages()
writeImageInCell()
writeChartInCell()
createCSSStyle()
createCSSStyleAlignment()
createCSSStyleFont()
createCSSStyleBorders()
createCSSStyleBorder()
createCSSStyleFill()
generateTableHeader()
generateTableFooter()
generateRow()
assembleCSS()
calculateSpans()
setMargins()
writeComment()
inchesToMm()
$saveArrayReturnType
$sheetIndex
$imagesRoot
$embedImages
$useInlineCss
$cssStyles
$columnWidths
$defaultFont
$spansAreCalculated
$isSpannedCell
$isBaseCell
$isSpannedRow
$generateSheetNavigationBlock
$useDiskCaching
$diskCachingDirectory
N/A

Properties

$tempDir

$tempDir : string

Temporary storage directory.

Type

string

$font

$font : string

Font.

Type

string

$orientation

$orientation : string

Orientation (Over-ride).

Type

string

$paperSize

$paperSize : int

Paper size (Over-ride).

Type

int

$paperSizes

$paperSizes : array

Paper Sizes xRef List.

Type

array

$spreadsheet

$spreadsheet : \PhpOffice\PhpSpreadsheet\Spreadsheet

Spreadsheet object.

Type

Spreadsheet

$isPdf

$isPdf : bool

Is the current writer creating PDF?

Type

bool

$includeCharts

$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;.

Type

bool

$preCalculateFormulas

$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.

Type

bool

$saveArrayReturnType

$saveArrayReturnType : string

Temporary storage for Save Array Return type.

Type

string

$sheetIndex

$sheetIndex : int

Sheet index to write.

Type

int

$imagesRoot

$imagesRoot : string

Images root.

Type

string

$embedImages

$embedImages : bool

embed images, or link to images.

Type

bool

$useInlineCss

$useInlineCss : bool

Use inline CSS?

Type

bool

$cssStyles

$cssStyles : array

Array of CSS styles.

Type

array

$columnWidths

$columnWidths : array

Array of column widths in points.

Type

array

$defaultFont

$defaultFont : \PhpOffice\PhpSpreadsheet\Style\Font

Default font.

Type

Font

$spansAreCalculated

$spansAreCalculated : bool

Flag whether spans have been calculated.

Type

bool

$isSpannedCell

$isSpannedCell : array

Excel cells that should not be written as HTML cells.

Type

array

$isBaseCell

$isBaseCell : array

Excel cells that are upper-left corner in a cell merge.

Type

array

$isSpannedRow

$isSpannedRow : array

Excel rows that should not be written as HTML rows.

Type

array

$generateSheetNavigationBlock

$generateSheetNavigationBlock : bool

Generate the Navigation block.

Type

bool

$useDiskCaching

$useDiskCaching : bool

Use disk caching where possible?

Type

bool

$diskCachingDirectory

$diskCachingDirectory : string

Disk caching directory.

Type

string

Methods

__construct()

__construct(\PhpOffice\PhpSpreadsheet\Spreadsheet  $spreadsheet) : mixed

Create a new HTML.

Parameters

\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet

Returns

mixed —

getFont()

getFont() : string

Get Font.

Returns

string —

setFont()

setFont(string  $fontName) : \PhpOffice\PhpSpreadsheet\Writer\Pdf

Set font. Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'.

Parameters

string $fontName

Returns

\PhpOffice\PhpSpreadsheet\Writer\Pdf —

getPaperSize()

getPaperSize() : int

Get Paper Size.

Returns

int —

setPaperSize()

setPaperSize(string  $pValue) : self

Set Paper Size.

Parameters

string $pValue

Paper size see PageSetup::PAPERSIZE_*

Returns

self —

getOrientation()

getOrientation() : string

Get Orientation.

Returns

string —

setOrientation()

setOrientation(string  $pValue) : self

Set Orientation.

Parameters

string $pValue

Page orientation see PageSetup::ORIENTATION_*

Returns

self —

getTempDir()

getTempDir() : string

Get temporary storage directory.

Returns

string —

setTempDir()

setTempDir(string  $pValue) : self

Set temporary storage directory.

Parameters

string $pValue

Temporary storage directory

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

when directory does not exist

Returns

self —

save()

save(string  $pFilename) : mixed

Save Spreadsheet to file.

Parameters

string $pFilename

Name of the file to save as

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception
\PhpOffice\PhpSpreadsheet\Exception

Returns

mixed —

getSheetIndex()

getSheetIndex() : int

Get sheet index.

Returns

int —

setSheetIndex()

setSheetIndex(int  $pValue) : \PhpOffice\PhpSpreadsheet\Writer\HTML

Set sheet index.

Parameters

int $pValue

Sheet index

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML —

getGenerateSheetNavigationBlock()

getGenerateSheetNavigationBlock() : bool

Get sheet index.

Returns

bool —

setGenerateSheetNavigationBlock()

setGenerateSheetNavigationBlock(bool  $pValue) : \PhpOffice\PhpSpreadsheet\Writer\HTML

Set sheet index.

Parameters

bool $pValue

Flag indicating whether the sheet navigation block should be generated or not

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML —

writeAllSheets()

writeAllSheets() : mixed

Write all sheets (resets sheetIndex to NULL).

Returns

mixed —

generateHTMLHeader()

generateHTMLHeader(bool  $pIncludeStyles = false) : string

Generate HTML header.

Parameters

bool $pIncludeStyles

Include styles?

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

string —

generateSheetData()

generateSheetData() : string

Generate sheet data.

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

string —

generateNavigation()

generateNavigation() : string

Generate sheet tabs.

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

string —

generateStyles()

generateStyles(bool  $generateSurroundingHTML = true) : string

Generate CSS styles.

Parameters

bool $generateSurroundingHTML

Generate surrounding HTML tags? (<style> and </style>)

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

string —

buildCSS()

buildCSS(bool  $generateSurroundingHTML = true) : array

Build CSS styles.

Parameters

bool $generateSurroundingHTML

Generate surrounding HTML style? (html { })

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

array —

generateHTMLFooter()

generateHTMLFooter() : mixed

Generate HTML footer.

Returns

mixed —

getImagesRoot()

getImagesRoot() : string

Get images root.

Returns

string —

setImagesRoot()

setImagesRoot(string  $pValue) : \PhpOffice\PhpSpreadsheet\Writer\HTML

Set images root.

Parameters

string $pValue

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML —

getEmbedImages()

getEmbedImages() : bool

Get embed images.

Returns

bool —

setEmbedImages()

setEmbedImages(bool  $pValue) : \PhpOffice\PhpSpreadsheet\Writer\HTML

Set embed images.

Parameters

bool $pValue

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML —

getUseInlineCss()

getUseInlineCss() : bool

Get use inline CSS?

Returns

bool —

setUseInlineCss()

setUseInlineCss(bool  $pValue) : \PhpOffice\PhpSpreadsheet\Writer\HTML

Set use inline CSS?

Parameters

bool $pValue

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML —

formatColor()

formatColor(string  $pValue, string  $pFormat) : string

Add color to formatted string as inline style.

Parameters

string $pValue

Plain formatted value without color

string $pFormat

Format code

Returns

string —

getIncludeCharts()

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.

If false (the default) it will ignore any charts defined in the PhpSpreadsheet object.

Returns

bool —

setIncludeCharts()

setIncludeCharts(mixed  $pValue) : \PhpOffice\PhpSpreadsheet\Writer\IWriter

Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.

Set to false (the default) to ignore charts.

Parameters

mixed $pValue

Returns

\PhpOffice\PhpSpreadsheet\Writer\IWriter —

getPreCalculateFormulas()

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.

Returns

bool —

setPreCalculateFormulas()

setPreCalculateFormulas(mixed  $pValue) : \PhpOffice\PhpSpreadsheet\Writer\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.

Parameters

mixed $pValue

Pre-Calculate Formulas?

Returns

\PhpOffice\PhpSpreadsheet\Writer\IWriter —

getUseDiskCaching()

getUseDiskCaching() : bool

Get use disk caching where possible?

Returns

bool —

setUseDiskCaching()

setUseDiskCaching(mixed  $pValue, mixed  $pDirectory = null) : \PhpOffice\PhpSpreadsheet\Writer\IWriter

Set use disk caching where possible?

Parameters

mixed $pValue
mixed $pDirectory

Disk caching directory

Returns

\PhpOffice\PhpSpreadsheet\Writer\IWriter —

getDiskCachingDirectory()

getDiskCachingDirectory() : string

Get disk caching directory.

Returns

string —

prepareForSave()

prepareForSave(string  $pFilename) : resource

Save Spreadsheet to PDF file, pre-save.

Parameters

string $pFilename

Name of the file to save as

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

resource —

restoreStateAfterSave()

restoreStateAfterSave(resource  $fileHandle) : mixed

Save PhpSpreadsheet to PDF file, post-save.

Parameters

resource $fileHandle

Returns

mixed —

createExternalWriterInstance()

createExternalWriterInstance(array  $config) : \Mpdf\Mpdf

Gets the implementation of external PDF library that should be used.

Parameters

array $config

Configuration array

Returns

\Mpdf\Mpdf —

implementation

mapVAlign()

mapVAlign(string  $vAlign) : string

Map VAlign.

Parameters

string $vAlign

Vertical alignment

Returns

string —

mapHAlign()

mapHAlign(string  $hAlign) : false|string

Map HAlign.

Parameters

string $hAlign

Horizontal alignment

Returns

false|string —

mapBorderStyle()

mapBorderStyle(int  $borderStyle) : string

Map border style.

Parameters

int $borderStyle

Sheet index

Returns

string —

extendRowsForChartsAndImages()

extendRowsForChartsAndImages(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet, mixed  $row) : mixed

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet
mixed $row

Returns

mixed —

writeImageInCell()

writeImageInCell(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet, string  $coordinates) : string

Generate image tag in cell.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

string $coordinates

Cell coordinates

Returns

string —

writeChartInCell()

writeChartInCell(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet, string  $coordinates) : string

Generate chart tag in cell.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

string $coordinates

Cell coordinates

Returns

string —

createCSSStyle()

createCSSStyle(\PhpOffice\PhpSpreadsheet\Style\Style  $pStyle) : array

Create CSS style.

Parameters

\PhpOffice\PhpSpreadsheet\Style\Style $pStyle

Returns

array —

createCSSStyleAlignment()

createCSSStyleAlignment(\PhpOffice\PhpSpreadsheet\Style\Alignment  $pStyle) : array

Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Alignment).

Parameters

\PhpOffice\PhpSpreadsheet\Style\Alignment $pStyle

\PhpOffice\PhpSpreadsheet\Style\Alignment

Returns

array —

createCSSStyleFont()

createCSSStyleFont(\PhpOffice\PhpSpreadsheet\Style\Font  $pStyle) : array

Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Font).

Parameters

\PhpOffice\PhpSpreadsheet\Style\Font $pStyle

Returns

array —

createCSSStyleBorders()

createCSSStyleBorders(\PhpOffice\PhpSpreadsheet\Style\Borders  $pStyle) : array

Create CSS style (Borders).

Parameters

\PhpOffice\PhpSpreadsheet\Style\Borders $pStyle

Borders

Returns

array —

createCSSStyleBorder()

createCSSStyleBorder(\PhpOffice\PhpSpreadsheet\Style\Border  $pStyle) : string

Create CSS style (Border).

Parameters

\PhpOffice\PhpSpreadsheet\Style\Border $pStyle

Border

Returns

string —

createCSSStyleFill()

createCSSStyleFill(\PhpOffice\PhpSpreadsheet\Style\Fill  $pStyle) : array

Create CSS style (Fill).

Parameters

\PhpOffice\PhpSpreadsheet\Style\Fill $pStyle

Fill

Returns

array —

generateTableHeader()

generateTableHeader(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet) : string

Generate table header.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

The worksheet for the table we are writing

Returns

string —

generateTableFooter()

generateTableFooter() : mixed

Generate table footer.

Returns

mixed —

generateRow()

generateRow(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet, array  $pValues, int  $pRow, string  $cellType) : string

Generate row.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

array $pValues

Array containing cells in a row

int $pRow

Row number (0-based)

string $cellType

eg: 'td'

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

string —

assembleCSS()

assembleCSS(array  $pValue = []) : string

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

Parameters

array $pValue

Returns

string —

calculateSpans()

calculateSpans() : mixed

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

Returns

mixed —

setMargins()

setMargins(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet) : mixed

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

Returns

mixed —

writeComment()

writeComment(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet, string  $coordinate) : string

Write a comment in the same format as LibreOffice.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet
string $coordinate

Returns

string —

inchesToMm()

inchesToMm(float  $inches) : float

Convert inches to mm.

Parameters

float $inches

Returns

float —