class Html extends BaseWriter (View source)

Properties

protected bool $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;. from BaseWriter
protected bool $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. from BaseWriter
protected Spreadsheet $spreadsheet Spreadsheet object.
protected bool $isPdf Is the current writer creating PDF?

Methods

bool
getIncludeCharts()

Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object.

setIncludeCharts(bool $pValue)

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

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

setPreCalculateFormulas(bool $pValue)

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.

bool
getUseDiskCaching()

Get use disk caching where possible?

setUseDiskCaching(bool $pValue, string $pDirectory = null)

Set use disk caching where possible?

string
getDiskCachingDirectory()

Get disk caching directory.

__construct(Spreadsheet $spreadsheet)

Create a new HTML.

save(string $pFilename)

Save Spreadsheet to file.

int
getSheetIndex()

Get sheet index.

HTML
setSheetIndex(int $pValue)

Set sheet index.

bool
getGenerateSheetNavigationBlock()

Get sheet index.

HTML
setGenerateSheetNavigationBlock(bool $pValue)

Set sheet index.

writeAllSheets()

Write all sheets (resets sheetIndex to NULL).

string
generateHTMLHeader(bool $pIncludeStyles = false)

Generate HTML header.

string
generateSheetData()

Generate sheet data.

string
generateNavigation()

Generate sheet tabs.

string
generateStyles(bool $generateSurroundingHTML = true)

Generate CSS styles.

array
buildCSS(bool $generateSurroundingHTML = true)

Build CSS styles.

generateHTMLFooter()

Generate HTML footer.

string
getImagesRoot()

Get images root.

HTML
setImagesRoot(string $pValue)

Set images root.

bool
getEmbedImages()

Get embed images.

HTML
setEmbedImages(bool $pValue)

Set embed images.

bool
getUseInlineCss()

Get use inline CSS?

HTML
setUseInlineCss(bool $pValue)

Set use inline CSS?

bool
getUseEmbeddedCSS()

Get use embedded CSS?

HTML
setUseEmbeddedCSS(bool $pValue)

Set use embedded CSS?

string
formatColor(string $pValue, string $pFormat)

Add color to formatted string as inline style.

Details

bool getIncludeCharts()

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.

Return Value

bool

IWriter setIncludeCharts(bool $pValue)

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

bool $pValue

Return Value

IWriter

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

Return Value

bool

IWriter setPreCalculateFormulas(bool $pValue)

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

bool $pValue Pre-Calculate Formulas?

Return Value

IWriter

bool getUseDiskCaching()

Get use disk caching where possible?

Return Value

bool

IWriter setUseDiskCaching(bool $pValue, string $pDirectory = null)

Set use disk caching where possible?

Parameters

bool $pValue
string $pDirectory Disk caching directory

Return Value

IWriter

Exceptions

Exception when directory does not exist

string getDiskCachingDirectory()

Get disk caching directory.

Return Value

string

__construct(Spreadsheet $spreadsheet)

Create a new HTML.

Parameters

Spreadsheet $spreadsheet

save(string $pFilename)

Save Spreadsheet to file.

Parameters

string $pFilename Name of the file to save

Exceptions

Exception

int getSheetIndex()

Get sheet index.

Return Value

int

HTML setSheetIndex(int $pValue)

Set sheet index.

Parameters

int $pValue Sheet index

Return Value

HTML

bool getGenerateSheetNavigationBlock()

Get sheet index.

Return Value

bool

HTML setGenerateSheetNavigationBlock(bool $pValue)

Set sheet index.

Parameters

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

Return Value

HTML

writeAllSheets()

Write all sheets (resets sheetIndex to NULL).

string generateHTMLHeader(bool $pIncludeStyles = false)

Generate HTML header.

Parameters

bool $pIncludeStyles Include styles?

Return Value

string

Exceptions

Exception

string generateSheetData()

Generate sheet data.

Return Value

string

Exceptions

Exception

string generateNavigation()

Generate sheet tabs.

Return Value

string

Exceptions

Exception

string generateStyles(bool $generateSurroundingHTML = true)

Generate CSS styles.

Parameters

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

Return Value

string

Exceptions

Exception

array buildCSS(bool $generateSurroundingHTML = true)

Build CSS styles.

Parameters

bool $generateSurroundingHTML Generate surrounding HTML style? (html { })

Return Value

array

Exceptions

Exception

generateHTMLFooter()

Generate HTML footer.

string getImagesRoot()

Get images root.

Return Value

string

HTML setImagesRoot(string $pValue)

Set images root.

Parameters

string $pValue

Return Value

HTML

bool getEmbedImages()

Get embed images.

Return Value

bool

HTML setEmbedImages(bool $pValue)

Set embed images.

Parameters

bool $pValue

Return Value

HTML

bool getUseInlineCss()

Get use inline CSS?

Return Value

bool

HTML setUseInlineCss(bool $pValue)

Set use inline CSS?

Parameters

bool $pValue

Return Value

HTML

bool getUseEmbeddedCSS()

Get use embedded CSS?

Return Value

bool

HTML setUseEmbeddedCSS(bool $pValue)

Set use embedded CSS?

Parameters

bool $pValue

Return Value

HTML

string formatColor(string $pValue, string $pFormat)

Add color to formatted string as inline style.

Parameters

string $pValue Plain formatted value without color
string $pFormat Format code

Return Value

string