Xlsx
extends BaseWriter
in package
Table of Contents
Constants
- DEFAULT_FORCE_FULL_CALC = false
Properties
- $fileHandle : resource
- $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.
- $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.
Methods
- __construct() : mixed
- Create a new Xlsx Writer.
- createStringTable() : array<string|int, RichText|string>
- createStyleDictionaries() : void
- getBordersHashTable() : HashTable<string|int, Borders>
- Get Borders HashTable.
- getDiskCachingDirectory() : string
- Get disk caching directory.
- getDrawingHashTable() : HashTable<string|int, BaseDrawing>
- Get \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\BaseDrawing HashTable.
- getExplicitStyle0() : bool
- getFillHashTable() : HashTable<string|int, Fill>
- Get Fill HashTable.
- getFontHashTable() : HashTable<string|int, Font>
- Get \PhpOffice\PhpSpreadsheet\Style\Font HashTable.
- 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.
- getNumFmtHashTable() : HashTable<string|int, NumberFormat>
- Get NumberFormat HashTable.
- getOffice2003Compatibility() : bool
- Get Office2003 compatibility.
- 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.
- getSpreadsheet() : Spreadsheet
- Get Spreadsheet object.
- getStringTable() : array<string|int, string>
- Get string table.
- getStyleHashTable() : HashTable<string|int, Style>
- Get Style HashTable.
- getStylesConditionalHashTable() : HashTable<string|int, Conditional>
- Get Conditional HashTable.
- getUseDiskCaching() : bool
- Get use disk caching where possible?
- getWriterPartChart() : Chart
- getWriterPartComments() : Comments
- getWriterPartContentTypes() : ContentTypes
- getWriterPartDocProps() : DocProps
- getWriterPartDrawing() : Drawing
- getWriterPartRels() : Rels
- getWriterPartRelsRibbon() : RelsRibbon
- getWriterPartRelsVBA() : RelsVBA
- getWriterPartStringTable() : StringTable
- getWriterPartStyle() : Style
- getWriterPartTable() : Table
- getWriterPartTheme() : Theme
- getWriterPartWorkbook() : Workbook
- getWriterPartWorksheet() : Worksheet
- openFileHandle() : void
- Open file handle.
- save() : void
- Save PhpSpreadsheet to file.
- setExplicitStyle0() : self
- This may be useful if non-default Alignment is part of default style and you think you might want to open the spreadsheet with LibreOffice or Gnumeric.
- setForceFullCalc() : self
- If this is set when a spreadsheet is opened, values may not be automatically re-calculated, and a button will be available to force re-calculation.
- setIncludeCharts() : $this
- Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.
- setOffice2003Compatibility() : $this
- Set Office2003 compatibility.
- 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.
- setSpreadsheet() : $this
- Set Spreadsheet object.
- setUseCSEArrays() : void
- setUseDiskCaching() : $this
- Set use disk caching where possible?
- useDynamicArrays() : bool
- maybeCloseFileHandle() : void
- Close file handle only if we opened it ourselves.
- processFlags() : void
Constants
DEFAULT_FORCE_FULL_CALC
public
mixed
DEFAULT_FORCE_FULL_CALC
= false
Properties
$fileHandle
protected
resource
$fileHandle
$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
$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
Methods
__construct()
Create a new Xlsx Writer.
public
__construct(Spreadsheet $spreadsheet) : mixed
Parameters
- $spreadsheet : Spreadsheet
-
The spreadsheet that we want to save using this Writer
createStringTable()
public
createStringTable() : array<string|int, RichText|string>
Return values
array<string|int, RichText|string> —$stringTable
createStyleDictionaries()
public
createStyleDictionaries() : void
getBordersHashTable()
Get Borders HashTable.
public
getBordersHashTable() : HashTable<string|int, Borders>
Return values
HashTable<string|int, Borders>getDiskCachingDirectory()
Get disk caching directory.
public
getDiskCachingDirectory() : string
Return values
stringgetDrawingHashTable()
Get \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\BaseDrawing HashTable.
public
getDrawingHashTable() : HashTable<string|int, BaseDrawing>
Return values
HashTable<string|int, BaseDrawing>getExplicitStyle0()
public
getExplicitStyle0() : bool
Return values
boolgetFillHashTable()
Get Fill HashTable.
public
getFillHashTable() : HashTable<string|int, Fill>
Return values
HashTable<string|int, Fill>getFontHashTable()
Get \PhpOffice\PhpSpreadsheet\Style\Font HashTable.
public
getFontHashTable() : HashTable<string|int, Font>
Return values
HashTable<string|int, Font>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
boolgetNumFmtHashTable()
Get NumberFormat HashTable.
public
getNumFmtHashTable() : HashTable<string|int, NumberFormat>
Return values
HashTable<string|int, NumberFormat>getOffice2003Compatibility()
Get Office2003 compatibility.
public
getOffice2003Compatibility() : bool
Return values
boolgetPreCalculateFormulas()
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
boolgetSpreadsheet()
Get Spreadsheet object.
public
getSpreadsheet() : Spreadsheet
Return values
SpreadsheetgetStringTable()
Get string table.
public
getStringTable() : array<string|int, string>
Return values
array<string|int, string>getStyleHashTable()
Get Style HashTable.
public
getStyleHashTable() : HashTable<string|int, Style>
Return values
HashTable<string|int, Style>getStylesConditionalHashTable()
Get Conditional HashTable.
public
getStylesConditionalHashTable() : HashTable<string|int, Conditional>
Return values
HashTable<string|int, Conditional>getUseDiskCaching()
Get use disk caching where possible?
public
getUseDiskCaching() : bool
Return values
boolgetWriterPartChart()
public
getWriterPartChart() : Chart
Return values
ChartgetWriterPartComments()
public
getWriterPartComments() : Comments
Return values
CommentsgetWriterPartContentTypes()
public
getWriterPartContentTypes() : ContentTypes
Return values
ContentTypesgetWriterPartDocProps()
public
getWriterPartDocProps() : DocProps
Return values
DocPropsgetWriterPartDrawing()
public
getWriterPartDrawing() : Drawing
Return values
DrawinggetWriterPartRels()
public
getWriterPartRels() : Rels
Return values
RelsgetWriterPartRelsRibbon()
public
getWriterPartRelsRibbon() : RelsRibbon
Return values
RelsRibbongetWriterPartRelsVBA()
public
getWriterPartRelsVBA() : RelsVBA
Return values
RelsVBAgetWriterPartStringTable()
public
getWriterPartStringTable() : StringTable
Return values
StringTablegetWriterPartStyle()
public
getWriterPartStyle() : Style
Return values
StylegetWriterPartTable()
public
getWriterPartTable() : Table
Return values
TablegetWriterPartTheme()
public
getWriterPartTheme() : Theme
Return values
ThemegetWriterPartWorkbook()
public
getWriterPartWorkbook() : Workbook
Return values
WorkbookgetWriterPartWorksheet()
public
getWriterPartWorksheet() : Worksheet
Return values
WorksheetopenFileHandle()
Open file handle.
public
openFileHandle(resource|string $filename) : void
Parameters
- $filename : resource|string
save()
Save PhpSpreadsheet to file.
public
save(resource|string $filename[, int $flags = 0 ]) : void
Parameters
- $filename : resource|string
- $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
setExplicitStyle0()
This may be useful if non-default Alignment is part of default style and you think you might want to open the spreadsheet with LibreOffice or Gnumeric.
public
setExplicitStyle0(bool $explicitStyle0) : self
Parameters
- $explicitStyle0 : bool
Return values
selfsetForceFullCalc()
If this is set when a spreadsheet is opened, values may not be automatically re-calculated, and a button will be available to force re-calculation.
public
setForceFullCalc(bool|null $forceFullCalc) : self
This may apply to all spreadsheets open at that time. If null, this will be set to the opposite of $preCalculateFormulas. It is likely that false is the desired setting, although cases have been reported where true is required (issue #456). Nevertheless, default is set to false in PhpSpreadsheet 4.0.0.
Parameters
- $forceFullCalc : bool|null
Return values
selfsetIncludeCharts()
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
$thissetOffice2003Compatibility()
Set Office2003 compatibility.
public
setOffice2003Compatibility(bool $office2003compatibility) : $this
Parameters
- $office2003compatibility : bool
-
Office2003 compatibility?
Return values
$thissetPreCalculateFormulas()
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
$thissetSpreadsheet()
Set Spreadsheet object.
public
setSpreadsheet(Spreadsheet $spreadsheet) : $this
Parameters
- $spreadsheet : Spreadsheet
-
PhpSpreadsheet object
Return values
$thissetUseCSEArrays()
public
setUseCSEArrays(bool|null $useCSEArrays) : void
Parameters
- $useCSEArrays : bool|null
setUseDiskCaching()
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
$thisuseDynamicArrays()
public
useDynamicArrays() : bool
Return values
boolmaybeCloseFileHandle()
Close file handle only if we opened it ourselves.
protected
maybeCloseFileHandle() : void
processFlags()
protected
processFlags(int $flags) : void
Parameters
- $flags : int