Properties

$includeCharts

$includeCharts : boolean

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

boolean

$preCalculateFormulas

$preCalculateFormulas : boolean

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

boolean

$isPdf

$isPdf : boolean

Is the current writer creating PDF?

Type

boolean

$useDiskCaching

$useDiskCaching : boolean

Use disk caching where possible?

Type

boolean

$diskCachingDirectory

$diskCachingDirectory : string

Disk caching directory.

Type

string

$sheetIndex

$sheetIndex : integer

Sheet index to write.

Type

integer

$imagesRoot

$imagesRoot : string

Images root.

Type

string

$embedImages

$embedImages : boolean

embed images, or link to images.

Type

boolean

$useInlineCss

$useInlineCss : boolean

Use inline CSS?

Type

boolean

$cssStyles

$cssStyles : array

Array of CSS styles.

Type

array

$columnWidths

$columnWidths : array

Array of column widths in points.

Type

array

$spansAreCalculated

$spansAreCalculated : boolean

Flag whether spans have been calculated.

Type

boolean

$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 : boolean

Generate the Navigation block.

Type

boolean

Methods

getIncludeCharts()

getIncludeCharts() : boolean

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

boolean

setIncludeCharts()

setIncludeCharts(boolean  $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

boolean $pValue

Returns

\PhpOffice\PhpSpreadsheet\Writer\IWriter

getPreCalculateFormulas()

getPreCalculateFormulas() : boolean

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

boolean

setPreCalculateFormulas()

setPreCalculateFormulas(boolean  $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

boolean $pValue

Pre-Calculate Formulas?

Returns

\PhpOffice\PhpSpreadsheet\Writer\IWriter

getUseDiskCaching()

getUseDiskCaching() : boolean

Get use disk caching where possible?

Returns

boolean

setUseDiskCaching()

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

Set use disk caching where possible?

Parameters

boolean $pValue
string $pDirectory

Disk caching directory

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

when directory does not exist

Returns

\PhpOffice\PhpSpreadsheet\Writer\IWriter

getDiskCachingDirectory()

getDiskCachingDirectory() : string

Get disk caching directory.

Returns

string

save()

save(string  $pFilename) 

Save Spreadsheet to file.

Parameters

string $pFilename

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

getSheetIndex()

getSheetIndex() : integer

Get sheet index.

Returns

integer

setSheetIndex()

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

Set sheet index.

Parameters

integer $pValue

Sheet index

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML

getGenerateSheetNavigationBlock()

getGenerateSheetNavigationBlock() : boolean

Get sheet index.

Returns

boolean

setGenerateSheetNavigationBlock()

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

Set sheet index.

Parameters

boolean $pValue

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

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML

writeAllSheets()

writeAllSheets() 

Write all sheets (resets sheetIndex to NULL).

generateHTMLHeader()

generateHTMLHeader(boolean  $pIncludeStyles = false) : string

Generate HTML header.

Parameters

boolean $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(boolean  $generateSurroundingHTML = true) : string

Generate CSS styles.

Parameters

boolean $generateSurroundingHTML

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

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

string

buildCSS()

buildCSS(boolean  $generateSurroundingHTML = true) : array

Build CSS styles.

Parameters

boolean $generateSurroundingHTML

Generate surrounding HTML style? (html { })

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

array

generateHTMLFooter()

generateHTMLFooter() 

Generate HTML footer.

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() : boolean

Get embed images.

Returns

boolean

setEmbedImages()

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

Set embed images.

Parameters

boolean $pValue

Returns

\PhpOffice\PhpSpreadsheet\Writer\HTML

getUseInlineCss()

getUseInlineCss() : boolean

Get use inline CSS?

Returns

boolean

setUseInlineCss()

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

Set use inline CSS?

Parameters

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

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(integer  $borderStyle) : string

Map border style.

Parameters

integer $borderStyle

Sheet index

Returns

string

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

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() 

Generate table footer.

generateRow()

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

Generate row.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

array $pValues

Array containing cells in a row

integer $pRow

Row number (0-based)

string $cellType

eg: 'td'

Throws

\PhpOffice\PhpSpreadsheet\Writer\Exception

Returns

string

assembleCSS()

assembleCSS(array  $pValue = array()) : string

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

Parameters

array $pValue

Returns

string

calculateSpans()

calculateSpans() 

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

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