Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
PhpOffice\PhpSpreadsheet\Reader\Xlsx Class Reference
Inheritance diagram for PhpOffice\PhpSpreadsheet\Reader\Xlsx:
PhpOffice\PhpSpreadsheet\Reader\BaseReader PhpOffice\PhpSpreadsheet\Reader\IReader

Public Member Functions

 __construct ()
 Create a new Xlsx Reader instance.
 
 canRead (string $filename)
 Can the current IReader read the file?
 
 getIgnoreRowsWithNoCells ()
 
 getIncludeCharts ()
 Read charts in workbook?
 
 getLoadSheetsOnly ()
 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 ()
 Read data only?
 
 getReadEmptyCells ()
 Read empty cells?
 
 getReadFilter ()
 Read filter.
 
 getSecurityScanner ()
 
 getSecurityScannerOrThrow ()
 
 getValueBinder ()
 
 listWorksheetInfo (string $filename)
 Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
 
 listWorksheetNames (string $filename)
 Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.
 
 load (string $filename, int $flags=0)
 Loads Spreadsheet from file.
 
 setIgnoreRowsWithNoCells (bool $ignoreRowsWithNoCells)
 
 setIncludeCharts (bool $includeCharts)
 Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook.
 
 setLoadAllSheets ()
 Set all sheets to load Tells the Reader to load all worksheets from the workbook.
 
 setLoadSheetsOnly (string|array|null $sheetList)
 Set which sheets to load.
 
 setReadDataOnly (bool $readCellValuesOnly)
 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 (bool $readEmptyCells)
 Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
 
 setReadFilter (IReadFilter $readFilter)
 Set read filter.
 
 setValueBinder (?IValueBinder $valueBinder)
 

Static Public Member Functions

static falseToArray (mixed $value)
 
static getAttributes (?SimpleXMLElement $value, string $ns='')
 
static replacePrefixes (string $formula)
 
static stripWhiteSpaceFromStyleString (string $string)
 
static testSimpleXml (mixed $value)
 

Public Attributes

const IGNORE_EMPTY_CELLS = 4
 Flag used to ignore empty cells when reading.
 
const IGNORE_ROWS_WITH_NO_CELLS = 8
 Flag used to ignore rows without cells.
 
const INITIAL_FILE = '_rels/.rels'
 
const LOAD_WITH_CHARTS = 1
 
const READ_DATA_ONLY = 2
 Flag used to read data only, not style or structure information.
 

Protected Member Functions

 loadSpreadsheetFromFile (string $filename)
 Loads Spreadsheet from file.
 
 openFile (string $filename)
 Open file for reading.
 
 processFlags (int $flags)
 

Protected Attributes

resource $fileHandle
 
bool $ignoreRowsWithNoCells = false
 Ignore rows with no cells?
 
bool $includeCharts = false
 Read charts that are defined in the workbook?
 
null string[] array $loadSheetsOnly = null
 Restrict which sheets should be loaded?
 
bool $readDataOnly = false
 
bool $readEmptyCells = true
 Read empty cells?
 
IReadFilter $readFilter
 IReadFilter instance.
 
XmlScanner $securityScanner = null
 
IValueBinder $valueBinder = null
 

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::__construct ( )

Create a new Xlsx Reader instance.

Reimplemented from PhpOffice\PhpSpreadsheet\Reader\BaseReader.

Member Function Documentation

◆ canRead()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::canRead ( string $filename)

Can the current IReader read the file?

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ getIncludeCharts()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::getIncludeCharts ( )
inherited

Read charts in workbook?

If this is true, then the Reader will include any charts that exist in the workbook. 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.

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ getLoadSheetsOnly()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::getLoadSheetsOnly ( )
inherited

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.

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ getReadDataOnly()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::getReadDataOnly ( )
inherited

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). If false (the default) it will read data and formatting.

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ getReadEmptyCells()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::getReadEmptyCells ( )
inherited

Read empty cells?

If this is true (the default), then the Reader will read data values for all cells, irrespective of value. If false it will not read data for cells containing a null value or an empty string.

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ getReadFilter()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::getReadFilter ( )
inherited

Read filter.

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ listWorksheetInfo()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::listWorksheetInfo ( string $filename)

Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).

Reimplemented from PhpOffice\PhpSpreadsheet\Reader\BaseReader.

◆ listWorksheetNames()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::listWorksheetNames ( string $filename)

Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object.

Reimplemented from PhpOffice\PhpSpreadsheet\Reader\BaseReader.

◆ load()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::load ( string $filename,
int $flags = 0 )
inherited

Loads Spreadsheet from file.

Parameters
int$flagsthe 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

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ loadSpreadsheetFromFile()

PhpOffice\PhpSpreadsheet\Reader\Xlsx::loadSpreadsheetFromFile ( string $filename)
protected

Loads Spreadsheet from file.

Reimplemented from PhpOffice\PhpSpreadsheet\Reader\BaseReader.

◆ setIncludeCharts()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::setIncludeCharts ( bool $includeCharts)
inherited

Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook.

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.

Return values
$this

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ setLoadAllSheets()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::setLoadAllSheets ( )
inherited

Set all sheets to load Tells the Reader to load all worksheets from the workbook.

Return values
$this

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ setLoadSheetsOnly()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::setLoadSheetsOnly ( string|array|null $value)
inherited

Set which sheets to load.

Parameters
null | array | string$valueThis should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. If NULL, then it tells the Reader to read all worksheets in the workbook
Return values
$this

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ setReadDataOnly()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::setReadDataOnly ( bool $readDataOnly)
inherited

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

Set to false (the default) to advise the Reader to read both data and formatting for cells.

Return values
$this

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ setReadEmptyCells()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::setReadEmptyCells ( bool $readEmptyCells)
inherited

Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.

Set to false to advise the Reader to ignore cells containing a null value or an empty string.

Return values
$this

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

◆ setReadFilter()

PhpOffice\PhpSpreadsheet\Reader\BaseReader::setReadFilter ( IReadFilter $readFilter)
inherited

Set read filter.

Return values
$this

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Member Data Documentation

◆ $ignoreRowsWithNoCells

bool PhpOffice\PhpSpreadsheet\Reader\BaseReader::$ignoreRowsWithNoCells = false
protectedinherited

Ignore rows with no cells?

Identifies whether the Reader should ignore rows with no cells. Currently implemented only for Xlsx.

◆ $includeCharts

bool PhpOffice\PhpSpreadsheet\Reader\BaseReader::$includeCharts = false
protectedinherited

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 string [] array PhpOffice\PhpSpreadsheet\Reader\BaseReader::$loadSheetsOnly = null
protectedinherited

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. This property is ignored for Csv, Html, and Slk.

◆ $readEmptyCells

bool PhpOffice\PhpSpreadsheet\Reader\BaseReader::$readEmptyCells = true
protectedinherited

Read empty cells?

Identifies whether the Reader should read data values for all cells, or should ignore cells containing null value or empty string.

◆ IGNORE_EMPTY_CELLS

const PhpOffice\PhpSpreadsheet\Reader\IReader::IGNORE_EMPTY_CELLS = 4
inherited

Flag used to ignore empty cells when reading.

The ignored cells will not be instantiated.

◆ IGNORE_ROWS_WITH_NO_CELLS

const PhpOffice\PhpSpreadsheet\Reader\IReader::IGNORE_ROWS_WITH_NO_CELLS = 8
inherited

Flag used to ignore rows without cells.

This flag is supported only for some formats. This can heavily improve performance for some files.


The documentation for this class was generated from the following file: