Xlsx
extends BaseReader
in package
Table of Contents
Constants
- INITIAL_FILE = '_rels/.rels'
- REL_TO_CHART = [\PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_RELATIONSHIPS => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_CHART]
- REL_TO_DRAWING = [\PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_RELATIONSHIPS => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_DRAWING]
- REL_TO_MAIN = [\PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_OFFICE_DOCUMENT => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_MAIN, \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::THUMBNAIL => '']
Properties
- $fileHandle : resource
- $ignoreRowsWithNoCells : bool
- Ignore rows with no cells? Identifies whether the Reader should ignore rows with no cells.
- $includeCharts : bool
- Read charts that are defined in the workbook? Identifies whether the Reader should read the definitions for any charts that exist in the workbook;.
- $loadSheetsOnly : null|array<string|int, string>
- Restrict which sheets should be loaded? This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
- $readDataOnly : bool
- Read data only? Identifies whether the Reader should only read data values for cells, and ignore any formatting information; or whether it should read both data and formatting.
- $readEmptyCells : bool
- Read empty cells? Identifies whether the Reader should read data values for all cells, or should ignore cells containing null value or empty string.
- $readFilter : IReadFilter
- IReadFilter instance.
- $securityScanner : XmlScanner|null
- $valueBinder : IValueBinder|null
- $referenceHelper : ReferenceHelper
- ReferenceHelper instance.
- $sharedFormulae : array<string|int, mixed>
- $styleReader : Styles
- $zip : ZipArchive
Methods
- __construct() : mixed
- Create a new Xlsx Reader instance.
- canRead() : bool
- Can the current IReader read the file?
- falseToArray() : array<string|int, mixed>
- getAttributes() : SimpleXMLElement
- getIgnoreRowsWithNoCells() : bool
- getIncludeCharts() : bool
- Read charts in workbook? If this is true, then the Reader will include any charts that exist in the workbook.
- getLoadSheetsOnly() : array<string|int, mixed>|null
- Get which sheets to load Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null indicating that all worksheets in the workbook should be loaded.
- getReadDataOnly() : bool
- Read data only? If this is true, then the Reader will only read data values for cells, it will not read any formatting or structural information (like merges).
- getReadEmptyCells() : bool
- Read empty cells? If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
- getReadFilter() : IReadFilter
- Read filter.
- getSecurityScanner() : XmlScanner|null
- getSecurityScannerOrThrow() : XmlScanner
- getValueBinder() : IValueBinder|null
- listWorksheetInfo() : array<string|int, mixed>
- Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
- listWorksheetNames() : array<string|int, mixed>
- Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.
- load() : Spreadsheet
- Loads Spreadsheet from file.
- replacePrefixes() : string
- setIgnoreRowsWithNoCells() : self
- setIncludeCharts() : $this
- Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook.
- setLoadAllSheets() : $this
- Set all sheets to load Tells the Reader to load all worksheets from the workbook.
- setLoadSheetsOnly() : $this
- Set which sheets to load.
- setReadDataOnly() : $this
- Set read data only Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting or structural information (like merges).
- setReadEmptyCells() : $this
- Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
- setReadFilter() : $this
- Set read filter.
- setValueBinder() : self
- stripWhiteSpaceFromStyleString() : string
- testSimpleXml() : SimpleXMLElement
- loadSpreadsheetFromFile() : Spreadsheet
- Loads Spreadsheet from file.
- openFile() : void
- Open file for reading.
- processFlags() : void
- boolean() : bool
- castToBoolean() : bool
- castToError() : string|null
- castToFormula() : void
- castToString() : string|null
- dirAdd() : string
- extractPalette() : array<string|int, mixed>
- extractStyles() : array<string|int, mixed>
- fileExistsInArchive() : bool
- getArrayItem() : mixed
- getArrayItemIntOrSxml() : int|SimpleXMLElement
- getArrayItemString() : string
- getFromZipArchive() : string
- getLockValue() : bool|null
- getWorkbookBaseName() : array<string|int, mixed>
- loadZip() : SimpleXMLElement
- loadZipNonamespace() : SimpleXMLElement
- onlyNoteVml() : bool
- parseRichText() : RichText
- processIgnoredErrors() : void
- readAutoFilter() : void
- readBackgroundImage() : void
- readFormControlProperties() : void
- readHyperLinkDrawing() : void
- readPrinterSettings() : void
- readProtection() : void
- readRibbon() : void
- readSheetProtection() : void
- readTables() : void
- readTablesInTablesFile() : void
- storeFormulaAttributes() : void
- toCSSArray() : array<string|int, mixed>
- xpathNoFalse() : array<string|int, mixed>
Constants
INITIAL_FILE
public
mixed
INITIAL_FILE
= '_rels/.rels'
REL_TO_CHART
private
mixed
REL_TO_CHART
= [\PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_RELATIONSHIPS => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_CHART]
REL_TO_DRAWING
private
mixed
REL_TO_DRAWING
= [\PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_RELATIONSHIPS => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_DRAWING]
REL_TO_MAIN
private
mixed
REL_TO_MAIN
= [\PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_OFFICE_DOCUMENT => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::PURL_MAIN, \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces::THUMBNAIL => '']
Properties
$fileHandle
protected
resource
$fileHandle
$ignoreRowsWithNoCells
Ignore rows with no cells? Identifies whether the Reader should ignore rows with no cells.
protected
bool
$ignoreRowsWithNoCells
= false
Currently implemented only for Xlsx.
$includeCharts
Read charts that are defined in the workbook? Identifies whether the Reader should read the definitions for any charts that exist in the workbook;.
protected
bool
$includeCharts
= false
$loadSheetsOnly
Restrict which sheets should be loaded? This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
protected
null|array<string|int, string>
$loadSheetsOnly
= null
This property is ignored for Csv, Html, and Slk.
$readDataOnly
Read data only? Identifies whether the Reader should only read data values for cells, and ignore any formatting information; or whether it should read both data and formatting.
protected
bool
$readDataOnly
= false
$readEmptyCells
Read empty cells? Identifies whether the Reader should read data values for all cells, or should ignore cells containing null value or empty string.
protected
bool
$readEmptyCells
= true
$readFilter
IReadFilter instance.
protected
IReadFilter
$readFilter
$securityScanner
protected
XmlScanner|null
$securityScanner
= null
$valueBinder
protected
IValueBinder|null
$valueBinder
= null
$referenceHelper
ReferenceHelper instance.
private
ReferenceHelper
$referenceHelper
$sharedFormulae
private
array<string|int, mixed>
$sharedFormulae
= []
$styleReader
private
Styles
$styleReader
$zip
private
ZipArchive
$zip
Methods
__construct()
Create a new Xlsx Reader instance.
public
__construct() : mixed
canRead()
Can the current IReader read the file?
public
canRead(string $filename) : bool
Parameters
- $filename : string
Return values
boolfalseToArray()
public
static falseToArray(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>getAttributes()
public
static getAttributes(SimpleXMLElement|null $value[, string $ns = '' ]) : SimpleXMLElement
Parameters
- $value : SimpleXMLElement|null
- $ns : string = ''
Return values
SimpleXMLElementgetIgnoreRowsWithNoCells()
public
getIgnoreRowsWithNoCells() : bool
Return values
boolgetIncludeCharts()
Read charts in workbook? If this is true, then the Reader will include any charts that exist in the workbook.
public
getIncludeCharts() : bool
Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. If false (the default) it will ignore any charts defined in the workbook file.
Return values
boolgetLoadSheetsOnly()
Get which sheets to load Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null indicating that all worksheets in the workbook should be loaded.
public
getLoadSheetsOnly() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetReadDataOnly()
Read data only? If this is true, then the Reader will only read data values for cells, it will not read any formatting or structural information (like merges).
public
getReadDataOnly() : bool
If false (the default) it will read data and formatting.
Return values
boolgetReadEmptyCells()
Read empty cells? If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
public
getReadEmptyCells() : bool
If false it will not read data for cells containing a null value or an empty string.
Return values
boolgetReadFilter()
Read filter.
public
getReadFilter() : IReadFilter
Return values
IReadFiltergetSecurityScanner()
public
getSecurityScanner() : XmlScanner|null
Return values
XmlScanner|nullgetSecurityScannerOrThrow()
public
getSecurityScannerOrThrow() : XmlScanner
Return values
XmlScannergetValueBinder()
public
getValueBinder() : IValueBinder|null
Return values
IValueBinder|nulllistWorksheetInfo()
Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
public
listWorksheetInfo(string $filename) : array<string|int, mixed>
Parameters
- $filename : string
Return values
array<string|int, mixed>listWorksheetNames()
Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.
public
listWorksheetNames(string $filename) : array<string|int, mixed>
Parameters
- $filename : string
Return values
array<string|int, mixed>load()
Loads Spreadsheet from file.
public
load(string $filename[, int $flags = 0 ]) : Spreadsheet
Parameters
- $filename : string
-
The name of the file to load
- $flags : int = 0
-
the optional second parameter flags may be used to identify specific elements that should be loaded, but which won't be loaded by default, using these values: IReader::LOAD_WITH_CHARTS - Include any charts that are defined in the loaded file
Return values
SpreadsheetreplacePrefixes()
public
static replacePrefixes(string $formula) : string
Parameters
- $formula : string
Return values
stringsetIgnoreRowsWithNoCells()
public
setIgnoreRowsWithNoCells(bool $ignoreRowsWithNoCells) : self
Parameters
- $ignoreRowsWithNoCells : bool
Return values
selfsetIncludeCharts()
Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook.
public
setIncludeCharts(bool $includeCharts) : $this
Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. Set to false (the default) to discard charts.
Parameters
- $includeCharts : bool
Return values
$thissetLoadAllSheets()
Set all sheets to load Tells the Reader to load all worksheets from the workbook.
public
setLoadAllSheets() : $this
Return values
$thissetLoadSheetsOnly()
Set which sheets to load.
public
setLoadSheetsOnly(string|array<string|int, mixed>|null $sheetList) : $this
Parameters
- $sheetList : string|array<string|int, mixed>|null
Return values
$thissetReadDataOnly()
Set read data only Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting or structural information (like merges).
public
setReadDataOnly(bool $readCellValuesOnly) : $this
Set to false (the default) to advise the Reader to read both data and formatting for cells.
Parameters
- $readCellValuesOnly : bool
Return values
$thissetReadEmptyCells()
Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
public
setReadEmptyCells(bool $readEmptyCells) : $this
Set to false to advise the Reader to ignore cells containing a null value or an empty string.
Parameters
- $readEmptyCells : bool
Return values
$thissetReadFilter()
Set read filter.
public
setReadFilter(IReadFilter $readFilter) : $this
Parameters
- $readFilter : IReadFilter
Return values
$thissetValueBinder()
public
setValueBinder(IValueBinder|null $valueBinder) : self
Parameters
- $valueBinder : IValueBinder|null
Return values
selfstripWhiteSpaceFromStyleString()
public
static stripWhiteSpaceFromStyleString(string $string) : string
Parameters
- $string : string
Return values
stringtestSimpleXml()
public
static testSimpleXml(mixed $value) : SimpleXMLElement
Parameters
- $value : mixed
Return values
SimpleXMLElementloadSpreadsheetFromFile()
Loads Spreadsheet from file.
protected
loadSpreadsheetFromFile(string $filename) : Spreadsheet
Parameters
- $filename : string
Return values
SpreadsheetopenFile()
Open file for reading.
protected
openFile(string $filename) : void
Parameters
- $filename : string
processFlags()
protected
processFlags(int $flags) : void
Parameters
- $flags : int
boolean()
private
static boolean(string $value) : bool
Parameters
- $value : string
Return values
boolcastToBoolean()
private
static castToBoolean(SimpleXMLElement $c) : bool
Parameters
- $c : SimpleXMLElement
Return values
boolcastToError()
private
static castToError(SimpleXMLElement|null $c) : string|null
Parameters
- $c : SimpleXMLElement|null
Return values
string|nullcastToFormula()
private
castToFormula(SimpleXMLElement|null $c, string $r, string &$cellDataType, mixed &$value, mixed &$calculatedValue, string $castBaseType[, bool $updateSharedCells = true ]) : void
Parameters
- $c : SimpleXMLElement|null
- $r : string
- $cellDataType : string
- $value : mixed
- $calculatedValue : mixed
- $castBaseType : string
- $updateSharedCells : bool = true
castToString()
private
static castToString(SimpleXMLElement|null $c) : string|null
Parameters
- $c : SimpleXMLElement|null
Return values
string|nulldirAdd()
private
static dirAdd(null|SimpleXMLElement|string $base, null|SimpleXMLElement|string $add) : string
Parameters
- $base : null|SimpleXMLElement|string
- $add : null|SimpleXMLElement|string
Return values
stringextractPalette()
private
static extractPalette(SimpleXMLElement|null $sxml) : array<string|int, mixed>
Parameters
- $sxml : SimpleXMLElement|null
Return values
array<string|int, mixed>extractStyles()
private
static extractStyles(SimpleXMLElement|null $sxml, string $node1, string $node2) : array<string|int, mixed>
Parameters
- $sxml : SimpleXMLElement|null
- $node1 : string
- $node2 : string
Return values
array<string|int, mixed>fileExistsInArchive()
private
fileExistsInArchive(ZipArchive $archive[, string $fileName = '' ]) : bool
Parameters
- $archive : ZipArchive
- $fileName : string = ''
Return values
boolgetArrayItem()
private
static getArrayItem(null|array<string|int, mixed>|bool|SimpleXMLElement $array[, int|string $key = 0 ]) : mixed
Parameters
- $array : null|array<string|int, mixed>|bool|SimpleXMLElement
- $key : int|string = 0
getArrayItemIntOrSxml()
private
static getArrayItemIntOrSxml(null|array<string|int, mixed>|bool|SimpleXMLElement $array[, int|string $key = 0 ]) : int|SimpleXMLElement
Parameters
- $array : null|array<string|int, mixed>|bool|SimpleXMLElement
- $key : int|string = 0
Return values
int|SimpleXMLElementgetArrayItemString()
private
static getArrayItemString(null|array<string|int, mixed>|bool|SimpleXMLElement $array[, int|string $key = 0 ]) : string
Parameters
- $array : null|array<string|int, mixed>|bool|SimpleXMLElement
- $key : int|string = 0
Return values
stringgetFromZipArchive()
private
getFromZipArchive(ZipArchive $archive[, string $fileName = '' ]) : string
Parameters
- $archive : ZipArchive
- $fileName : string = ''
Return values
stringgetLockValue()
private
static getLockValue(SimpleXMLElement $protection, string $key) : bool|null
Parameters
- $protection : SimpleXMLElement
- $key : string
Return values
bool|nullgetWorkbookBaseName()
private
getWorkbookBaseName() : array<string|int, mixed>
Return values
array<string|int, mixed>loadZip()
private
loadZip(string $filename[, string $ns = '' ][, bool $replaceUnclosedBr = false ]) : SimpleXMLElement
Parameters
- $filename : string
- $ns : string = ''
- $replaceUnclosedBr : bool = false
Return values
SimpleXMLElementloadZipNonamespace()
private
loadZipNonamespace(string $filename, string $ns) : SimpleXMLElement
Parameters
- $filename : string
- $ns : string
Return values
SimpleXMLElementonlyNoteVml()
private
static onlyNoteVml(string $data) : bool
Parameters
- $data : string
Return values
boolparseRichText()
private
parseRichText(SimpleXMLElement|null $is) : RichText
Parameters
- $is : SimpleXMLElement|null
Return values
RichTextprocessIgnoredErrors()
private
processIgnoredErrors(SimpleXMLElement $xml, Worksheet $sheet) : void
Parameters
- $xml : SimpleXMLElement
- $sheet : Worksheet
readAutoFilter()
private
readAutoFilter(SimpleXMLElement $xmlSheet, Worksheet $docSheet) : void
Parameters
- $xmlSheet : SimpleXMLElement
- $docSheet : Worksheet
readBackgroundImage()
private
readBackgroundImage(SimpleXMLElement $xmlSheet, Worksheet $docSheet, string $relsName) : void
Parameters
- $xmlSheet : SimpleXMLElement
- $docSheet : Worksheet
- $relsName : string
readFormControlProperties()
private
readFormControlProperties(Spreadsheet $excel, string $dir, string $fileWorksheet, Worksheet $docSheet, array<string|int, mixed> &$unparsedLoadedData) : void
Parameters
- $excel : Spreadsheet
- $dir : string
- $fileWorksheet : string
- $docSheet : Worksheet
- $unparsedLoadedData : array<string|int, mixed>
readHyperLinkDrawing()
private
readHyperLinkDrawing(Drawing $objDrawing, SimpleXMLElement $cellAnchor, array<string|int, mixed> $hyperlinks) : void
Parameters
- $objDrawing : Drawing
- $cellAnchor : SimpleXMLElement
- $hyperlinks : array<string|int, mixed>
readPrinterSettings()
private
readPrinterSettings(Spreadsheet $excel, string $dir, string $fileWorksheet, Worksheet $docSheet, array<string|int, mixed> &$unparsedLoadedData) : void
Parameters
- $excel : Spreadsheet
- $dir : string
- $fileWorksheet : string
- $docSheet : Worksheet
- $unparsedLoadedData : array<string|int, mixed>
readProtection()
private
readProtection(Spreadsheet $excel, SimpleXMLElement $xmlWorkbook) : void
Parameters
- $excel : Spreadsheet
- $xmlWorkbook : SimpleXMLElement
readRibbon()
private
readRibbon(Spreadsheet $excel, string $customUITarget, ZipArchive $zip) : void
Parameters
- $excel : Spreadsheet
- $customUITarget : string
- $zip : ZipArchive
readSheetProtection()
private
readSheetProtection(Worksheet $docSheet, SimpleXMLElement $xmlSheet) : void
Parameters
- $docSheet : Worksheet
- $xmlSheet : SimpleXMLElement
readTables()
private
readTables(SimpleXMLElement $xmlSheet, Worksheet $docSheet, string $dir, string $fileWorksheet, ZipArchive $zip, string $namespaceTable) : void
Parameters
- $xmlSheet : SimpleXMLElement
- $docSheet : Worksheet
- $dir : string
- $fileWorksheet : string
- $zip : ZipArchive
- $namespaceTable : string
readTablesInTablesFile()
private
readTablesInTablesFile(SimpleXMLElement $xmlSheet, string $dir, string $fileWorksheet, ZipArchive $zip, Worksheet $docSheet, string $namespaceTable) : void
Parameters
- $xmlSheet : SimpleXMLElement
- $dir : string
- $fileWorksheet : string
- $zip : ZipArchive
- $docSheet : Worksheet
- $namespaceTable : string
storeFormulaAttributes()
private
static storeFormulaAttributes(SimpleXMLElement $f, Worksheet $docSheet, string $r) : void
Parameters
- $f : SimpleXMLElement
- $docSheet : Worksheet
- $r : string
toCSSArray()
private
static toCSSArray(string $style) : array<string|int, mixed>
Parameters
- $style : string
Return values
array<string|int, mixed>xpathNoFalse()
private
static xpathNoFalse(SimpleXMLElement $sxml, string $path) : array<string|int, mixed>
Parameters
- $sxml : SimpleXMLElement
- $path : string