Gnumeric
extends BaseReader
in package
Table of Contents
Constants
- NAMESPACE_DC = 'http://purl.org/dc/elements/1.1/'
- NAMESPACE_GNM = 'http://www.gnumeric.org/v10.dtd'
- NAMESPACE_META = 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'
- NAMESPACE_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'
- NAMESPACE_OOO = 'http://openoffice.org/2004/office'
- NAMESPACE_XLINK = 'http://www.w3.org/1999/xlink'
- NAMESPACE_XSI = 'http://www.w3.org/2001/XMLSchema-instance'
Properties
- $mappings : array<string|int, mixed>
- $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
- $expressions : array<string|int, mixed>
- Shared Expressions.
- $referenceHelper : ReferenceHelper
- $spreadsheet : Spreadsheet
- Spreadsheet shared across all functions.
Methods
- __construct() : mixed
- Create a new Gnumeric.
- canRead() : bool
- Can the current IReader read the file?
- 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
- gnumericMappings() : array<string|int, mixed>
- 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.
- loadIntoExisting() : Spreadsheet
- Loads from file into Spreadsheet instance.
- 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
- loadSpreadsheetFromFile() : Spreadsheet
- Loads Spreadsheet from file.
- openFile() : void
- Open file for reading.
- processFlags() : void
- getArrayFormulaRange() : string
- gzfileGetContents() : string
- loadCell() : void
- matchXml() : bool
- parseRichText() : RichText
- processAutofilter() : void
- processColumnLoop() : int
- processColumnWidths() : void
- processComments() : void
- processDefinedNames() : void
- processMergedCells() : void
- processRowHeights() : void
- processRowLoop() : int
- setColumnInvisible() : void
- setColumnWidth() : void
- setRowHeight() : void
- setRowInvisible() : void
- setSelectedCells() : void
- setSelectedSheet() : void
- testSimpleXml() : SimpleXMLElement
Constants
NAMESPACE_DC
public
mixed
NAMESPACE_DC
= 'http://purl.org/dc/elements/1.1/'
NAMESPACE_GNM
public
mixed
NAMESPACE_GNM
= 'http://www.gnumeric.org/v10.dtd'
NAMESPACE_META
public
mixed
NAMESPACE_META
= 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'
NAMESPACE_OFFICE
public
mixed
NAMESPACE_OFFICE
= 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'
NAMESPACE_OOO
public
mixed
NAMESPACE_OOO
= 'http://openoffice.org/2004/office'
NAMESPACE_XLINK
public
mixed
NAMESPACE_XLINK
= 'http://www.w3.org/1999/xlink'
NAMESPACE_XSI
public
mixed
NAMESPACE_XSI
= 'http://www.w3.org/2001/XMLSchema-instance'
Properties
$mappings
public
static array<string|int, mixed>
$mappings
= ['dataType' => [
'10' => \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NULL,
'20' => \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_BOOL,
'30' => \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC,
// Integer doesn't exist in Excel
'40' => \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC,
// Float
'50' => \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_ERROR,
'60' => \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING,
]]
$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
$expressions
Shared Expressions.
private
array<string|int, mixed>
$expressions
= []
$referenceHelper
private
ReferenceHelper
$referenceHelper
$spreadsheet
Spreadsheet shared across all functions.
private
Spreadsheet
$spreadsheet
Methods
__construct()
Create a new Gnumeric.
public
__construct() : mixed
canRead()
Can the current IReader read the file?
public
canRead(string $filename) : bool
Parameters
- $filename : string
Return values
boolgetIgnoreRowsWithNoCells()
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|nullgnumericMappings()
public
static gnumericMappings() : array<string|int, mixed>
Return values
array<string|int, mixed>listWorksheetInfo()
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
SpreadsheetloadIntoExisting()
Loads from file into Spreadsheet instance.
public
loadIntoExisting(string $filename, Spreadsheet $spreadsheet) : Spreadsheet
Parameters
- $filename : string
- $spreadsheet : Spreadsheet
Return values
SpreadsheetsetIgnoreRowsWithNoCells()
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
selfloadSpreadsheetFromFile()
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
getArrayFormulaRange()
private
getArrayFormulaRange(string $column, int $row, int $cols, int $rows) : string
Parameters
- $column : string
- $row : int
- $cols : int
- $rows : int
Return values
stringgzfileGetContents()
private
gzfileGetContents(string $filename) : string
Parameters
- $filename : string
Return values
stringloadCell()
private
loadCell(SimpleXMLElement $cell, string $worksheetName, SimpleXMLElement $cellAttributes, string $column, int $row) : void
Parameters
- $cell : SimpleXMLElement
- $worksheetName : string
- $cellAttributes : SimpleXMLElement
- $column : string
- $row : int
matchXml()
private
static matchXml(XMLReader $xml, string $expectedLocalName) : bool
Parameters
- $xml : XMLReader
- $expectedLocalName : string
Return values
boolparseRichText()
private
parseRichText(string $is) : RichText
Parameters
- $is : string
Return values
RichTextprocessAutofilter()
private
processAutofilter(SimpleXMLElement|null $sheet) : void
Parameters
- $sheet : SimpleXMLElement|null
processColumnLoop()
private
processColumnLoop(int $whichColumn, int $maxCol, SimpleXMLElement|null $columnOverride, float $defaultWidth) : int
Parameters
- $whichColumn : int
- $maxCol : int
- $columnOverride : SimpleXMLElement|null
- $defaultWidth : float
Return values
intprocessColumnWidths()
private
processColumnWidths(SimpleXMLElement|null $sheet, int $maxCol) : void
Parameters
- $sheet : SimpleXMLElement|null
- $maxCol : int
processComments()
private
processComments(SimpleXMLElement $sheet) : void
Parameters
- $sheet : SimpleXMLElement
processDefinedNames()
private
processDefinedNames(SimpleXMLElement|null $gnmXML) : void
Parameters
- $gnmXML : SimpleXMLElement|null
processMergedCells()
private
processMergedCells(SimpleXMLElement|null $sheet) : void
Parameters
- $sheet : SimpleXMLElement|null
processRowHeights()
private
processRowHeights(SimpleXMLElement|null $sheet, int $maxRow) : void
Parameters
- $sheet : SimpleXMLElement|null
- $maxRow : int
processRowLoop()
private
processRowLoop(int $whichRow, int $maxRow, SimpleXMLElement|null $rowOverride, float $defaultHeight) : int
Parameters
- $whichRow : int
- $maxRow : int
- $rowOverride : SimpleXMLElement|null
- $defaultHeight : float
Return values
intsetColumnInvisible()
private
setColumnInvisible(int $whichColumn) : void
Parameters
- $whichColumn : int
setColumnWidth()
private
setColumnWidth(int $whichColumn, float $defaultWidth) : void
Parameters
- $whichColumn : int
- $defaultWidth : float
setRowHeight()
private
setRowHeight(int $whichRow, float $defaultHeight) : void
Parameters
- $whichRow : int
- $defaultHeight : float
setRowInvisible()
private
setRowInvisible(int $whichRow) : void
Parameters
- $whichRow : int
setSelectedCells()
private
setSelectedCells(SimpleXMLElement|null $sheet) : void
Parameters
- $sheet : SimpleXMLElement|null
setSelectedSheet()
private
setSelectedSheet(SimpleXMLElement $gnmXML) : void
Parameters
- $gnmXML : SimpleXMLElement
testSimpleXml()
private
static testSimpleXml(mixed $value) : SimpleXMLElement
Parameters
- $value : mixed