Xlsx
extends BaseWriter
in package
Table of Contents
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.
- $bordersHashTable : HashTable<string|int, Borders>
- Private unique Borders HashTable.
- $diskCachingDirectory : string
- Disk caching directory.
- $drawingHashTable : HashTable<string|int, BaseDrawing>
- Private unique \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\BaseDrawing HashTable.
- $explicitStyle0 : bool
- $fillHashTable : HashTable<string|int, Fill>
- Private unique Fill HashTable.
- $fontHashTable : HashTable<string|int, Font>
- Private unique \PhpOffice\PhpSpreadsheet\Style\Font HashTable.
- $numFmtHashTable : HashTable<string|int, NumberFormat>
- Private unique NumberFormat HashTable.
- $office2003compatibility : bool
- Office2003 compatibility.
- $pathNames : array<string|int, mixed>
- $shouldCloseFile : bool
- $spreadSheet : Spreadsheet
- Private Spreadsheet.
- $stringTable : array<string|int, string>
- Private string table.
- $styleHashTable : HashTable<string|int, Style>
- Private unique Style HashTable.
- $stylesConditionalHashTable : HashTable<string|int, Conditional>
- Private unique Conditional HashTable.
- $useCSEArrays : bool
- $useDiskCaching : bool
- Use disk caching where possible?
- $useDynamicArray : bool
- $writerPartChart : Chart
- $writerPartComments : Comments
- $writerPartContentTypes : ContentTypes
- $writerPartDocProps : DocProps
- $writerPartDrawing : Drawing
- $writerPartRels : Rels
- $writerPartRelsRibbon : RelsRibbon
- $writerPartRelsVBA : RelsVBA
- $writerPartStringTable : StringTable
- $writerPartStyle : Style
- $writerPartTable : Table
- $writerPartTheme : Theme
- $writerPartWorkbook : Workbook
- $writerPartWorksheet : Worksheet
- $zip : ZipStream
- Private handle for zip stream.
Methods
- __construct() : mixed
- Create a new Xlsx Writer.
- 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.
- 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
- addZipFile() : void
- addZipFiles() : void
- determineUseDynamicArrays() : void
- processDrawing() : string|null|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
$bordersHashTable
Private unique Borders HashTable.
private
HashTable<string|int, Borders>
$bordersHashTable
$diskCachingDirectory
Disk caching directory.
private
string
$diskCachingDirectory
= './'
$drawingHashTable
Private unique \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\BaseDrawing HashTable.
private
HashTable<string|int, BaseDrawing>
$drawingHashTable
$explicitStyle0
private
bool
$explicitStyle0
= false
$fillHashTable
Private unique Fill HashTable.
private
HashTable<string|int, Fill>
$fillHashTable
$fontHashTable
Private unique \PhpOffice\PhpSpreadsheet\Style\Font HashTable.
private
HashTable<string|int, Font>
$fontHashTable
$numFmtHashTable
Private unique NumberFormat HashTable.
private
HashTable<string|int, NumberFormat>
$numFmtHashTable
$office2003compatibility
Office2003 compatibility.
private
bool
$office2003compatibility
= false
$pathNames
private
array<string|int, mixed>
$pathNames
= []
$shouldCloseFile
private
bool
$shouldCloseFile
$spreadSheet
Private Spreadsheet.
private
Spreadsheet
$spreadSheet
$stringTable
Private string table.
private
array<string|int, string>
$stringTable
= []
$styleHashTable
Private unique Style HashTable.
private
HashTable<string|int, Style>
$styleHashTable
$stylesConditionalHashTable
Private unique Conditional HashTable.
private
HashTable<string|int, Conditional>
$stylesConditionalHashTable
$useCSEArrays
private
bool
$useCSEArrays
= false
$useDiskCaching
Use disk caching where possible?
private
bool
$useDiskCaching
= false
$useDynamicArray
private
bool
$useDynamicArray
= false
$writerPartChart
private
Chart
$writerPartChart
$writerPartComments
private
Comments
$writerPartComments
$writerPartContentTypes
private
ContentTypes
$writerPartContentTypes
$writerPartDocProps
private
DocProps
$writerPartDocProps
$writerPartDrawing
private
Drawing
$writerPartDrawing
$writerPartRels
private
Rels
$writerPartRels
$writerPartRelsRibbon
private
RelsRibbon
$writerPartRelsRibbon
$writerPartRelsVBA
private
RelsVBA
$writerPartRelsVBA
$writerPartStringTable
private
StringTable
$writerPartStringTable
$writerPartStyle
private
Style
$writerPartStyle
$writerPartTable
private
Table
$writerPartTable
$writerPartTheme
private
Theme
$writerPartTheme
$writerPartWorkbook
private
Workbook
$writerPartWorkbook
$writerPartWorksheet
private
Worksheet
$writerPartWorksheet
$zip
Private handle for zip stream.
private
ZipStream
$zip
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
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
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
addZipFile()
private
addZipFile(string $path, string $content) : void
Parameters
- $path : string
- $content : string
addZipFiles()
private
addZipFiles(array<string|int, mixed> $zipContent) : void
Parameters
- $zipContent : array<string|int, mixed>
determineUseDynamicArrays()
private
determineUseDynamicArrays() : void
processDrawing()
private
processDrawing(Drawing $drawing) : string|null|false
Parameters
- $drawing : Drawing