Class \avadim\FastExcelReader\Sheet
On this page
- __construct()
- Parameters
- actualDimension()
- Parameters
- countActualColumns()
- Parameters
- countActualDimension()
- Parameters
- countActualRows()
- Parameters
- countCols()
- Parameters
- countColumns()
- Parameters
- countImages()
- Parameters
- countRows()
- Parameters
- dimension()
- Parameters
- dimensionArray()
- Parameters
- extractConditionalFormatting()
- Parameters
- extractDataValidations()
- Parameters
- extractHyperlinks()
- Parameters
- firstCol()
- Parameters
- firstRow()
- Parameters
- from()
- Parameters
- getAllColAttributes()
- Parameters
- getAllRowAttributes()
- Parameters
- getColumnAttributes()
- Parameters
- getColumnStyle()
- Parameters
- getColumnWidth()
- Parameters
- getConditionalFormatting()
- Parameters
- getDataValidations()
- Parameters
- getFreezePaneInfo()
- Parameters
- getHyperlinks()
- Parameters
- getImageBlob()
- Parameters
- getImageList()
- Parameters
- getImageListByRow()
- Parameters
- getImageMimeType()
- Parameters
- getImageName()
- Parameters
- getMergedCells()
- Parameters
- getReadRowNum()
- Parameters
- getRowAttributes()
- Parameters
- getRowHeight()
- Parameters
- getRowStyle()
- Parameters
- getTabColorConfiguration()
- Parameters
- getTabColorInfo()
- Parameters
- hasDrawings()
- Parameters
- hasImage()
- Parameters
- id()
- Parameters
- imageEntryFullPath()
- Parameters
- isActive()
- Parameters
- isHidden()
- Parameters
- isMerged()
- Parameters
- isName()
- Parameters
- isVisible()
- Parameters
- maxActualColumn()
- Parameters
- maxActualRow()
- Parameters
- maxColumn()
- Parameters
- maxRow()
- Parameters
- mergedRange()
- Parameters
- minActualColumn()
- Parameters
- minActualRow()
- Parameters
- minColumn()
- Parameters
- minRow()
- Parameters
- name()
- Parameters
- nextRow()
- Parameters
- path()
- Parameters
- readCallback()
- Parameters
- readCells()
- Parameters
- readCellsFrom()
- Parameters
- readCellStyles()
- Parameters
- readCellsWithStyles()
- Parameters
- readCellsWithStylesFrom()
- Parameters
- readColumns()
- Parameters
- readColumnsFrom()
- Parameters
- readColumnsWithStyles()
- Parameters
- readColumnsWithStylesFrom()
- Parameters
- readFirstRow()
- Parameters
- readFirstRowCells()
- Parameters
- readFirstRowCellsFrom()
- Parameters
- readFirstRowFrom()
- Parameters
- readFirstRowWithStyles()
- Parameters
- readFirstRowWithStylesFrom()
- Parameters
- readNextRow()
- Parameters
- readRows()
- Parameters
- readRowsFrom()
- Parameters
- readRowsWithStyles()
- Parameters
- readRowsWithStylesFrom()
- Parameters
- reset()
- Parameters
- rewind()
- Parameters
- saveImage()
- Parameters
- saveImageTo()
- Parameters
- setDateFormat()
- Parameters
- setDefaultRowHeight()
- Parameters
- setReadArea()
- Parameters
- Examples
- setReadAreaColumns()
- Parameters
- setState()
- Parameters
- stat()
- Parameters
- state()
- Parameters
- withHeader()
- Parameters
- __construct()
- actualDimension() – Get the actual dimension range (e.g. "A1:C10")
- countActualColumns() – Returns the actual number of columns from the sheet data area
- countActualDimension() – Scan sheet data and returns actual number of rows and columns
- countActualRows() – Returns the actual number of rows from the sheet data area
- countCols() – Count columns by dimension value, alias of countColumns()
- countColumns() – Count columns by dimension value
- countImages() – Count images of the sheet
- countRows() – Count rows by dimension value
- dimension() – Get sheet dimension range (e.g. "A1:C10")
- dimensionArray() – Get sheet dimension as an array
- extractConditionalFormatting() – Extracts conditional formatting rules from the sheet
- extractDataValidations() – Extracts data validation rules from the sheet
- extractHyperlinks() – Extracts the
section of the sheet and resolves external targets from the sheet relationships file - firstCol() – Get letter of the first column in the read area
- firstRow() – Get number of the first row in the read area
- from() – Set top left of read area. Alias of setReadArea()
- getAllColAttributes() – Get all column attributes
- getAllRowAttributes() – Read all row attributes to the array
- getColumnAttributes() – Get column attributes (width, style, etc)
- getColumnStyle() – Get column style
- getColumnWidth() – Get width of the column
- getConditionalFormatting() – Get conditional formatting rules
- getDataValidations() – Get data validation rules
- getFreezePaneInfo() – Get freeze pane info
- getHyperlinks() – Get cell hyperlinks, keyed by the cell (or range) they are anchored to
- getImageBlob() – Get image content as binary string
- getImageList() – Get image list
- getImageListByRow() – Get image list by row number
- getImageMimeType() – Get image MIME type
- getImageName() – Get image name
- getMergedCells() – Get merged cells. Returns an array [min_cell => range]
- getReadRowNum() – Get the number of the last row read
- getRowAttributes() – Get row attributes (height, style, etc)
- getRowHeight() – Get height of the row
- getRowStyle() – Get row style
- getTabColorConfiguration() – Get tab color configuration. Alias of getTabColorConfig()
- getTabColorInfo() – Get the tab color info of the sheet
- hasDrawings() – Returns true if the sheet has drawings
- hasImage() – Returns TRUE if the cell contains an image
- id() – Get sheet ID
- imageEntryFullPath() – Get full path to the image in the ZIP archive
- isActive() – Returns true if the sheet is active
- isHidden() – Returns true if the sheet is hidden
- isMerged() – Returns true if the cell is merged
- isName() – Case-insensitive name checking
- isVisible() – Returns true if the sheet is visible
- maxActualColumn() – Get the last actual column letter
- maxActualRow() – Get the last actual row number
- maxColumn() – Max column from dimension value
- maxRow() – Max row number from dimension value
- mergedRange() – Get merged range for the cell
- minActualColumn() – Get the first actual column letter
- minActualRow() – Get the first actual row number
- minColumn() – Min column from dimension value
- minRow() – Min row number from dimension value
- name() – Get sheet name
- nextRow() – Read cell values row by row, returns either an array of values or an array of arrays
- path() – Get path to the sheet XML file in ZIP archive
- readCallback() – Reads cell values and passes them to a callback function
- readCells() – Returns values and styles of cells as array
- readCellsFrom() – Set read area and returns cell values as a one-dimensional array [address => value]
- readCellStyles() – Returns styles of cells as array
- readCellsWithStyles() – Returns cell values and styles as a one-dimensional array [address => value]:
- readCellsWithStylesFrom() – Set read area and returns cell values and styles as a one-dimensional array [address => value]
- readColumns() – Returns cell values as a two-dimensional array from default sheet [col][row]
- readColumnsFrom() – Set read area and returns cell values as a two-dimensional array from default sheet [col][row]
- readColumnsWithStyles() – Returns cell values and styles as a two-dimensional array [column][row]
- readColumnsWithStylesFrom() – Set read area and returns cell values and styles as a two-dimensional array [column][row]
- readFirstRow() – Returns values of cells of 1st row as array
- readFirstRowCells() – Returns values and styles of cells of 1st row as array
- readFirstRowCellsFrom() – Set read area and returns cell values of 1st row as array [address => value]
- readFirstRowFrom() – Set read area and returns values of cells of 1st row as array
- readFirstRowWithStyles() – Returns values and styles of cells of 1st row as array
- readFirstRowWithStylesFrom() – Set read area and returns values and styles of cells of 1st row as array
- readNextRow() – Read the next row from the generator
- readRows() – Returns cell values as a two-dimensional array
- readRowsFrom() – Read rows from a given area $areaRange
- readRowsWithStyles() – Returns values, styles, and other info of cells as array
- readRowsWithStylesFrom() – Set read area and returns values, styles, and other info of cells as array
- reset() – Reset read generator
- rewind() – Rewind read generator, alias of reset()
- saveImage() – Save image to a file
- saveImageTo() – Save image to a directory
- setDateFormat() – Set date format
- setDefaultRowHeight() – Set default row height
- setReadArea() – Set top left and right bottom of read area
- setReadAreaColumns() – setReadArea('C:AZ') - set left and right columns of read area
- setState() – Set sheet state (visible, hidden, veryHidden)
- stat() – Returns statistics of the sheet: rows, columns and cell counts
- state() – Get sheet state
- withHeader() – Enables header mode
__construct()
public function __construct(string $sheetName, string $sheetId, string $file,
string $path, $excel)
Parameters
string $sheetNamestring $sheetIdstring $filestring $path$excel
actualDimension()
public function actualDimension(): string
Get the actual dimension range (e.g. "A1:C10")
Note: scans every cell of the sheet (see countActualDimension()); expensive on wide sheets.
Parameters
None
countActualColumns()
public function countActualColumns(): int
Returns the actual number of columns from the sheet data area
Note: scans every cell of the sheet (see countActualDimension()); expensive on wide sheets.
Parameters
None
countActualDimension()
public function countActualDimension(bool $countColumns = true,
bool $countRows = true,
int $blockSize = 4096): array
Scan sheet data and returns actual number of rows and columns
Note: this method performs a full streaming pass over the (decompressed) sheet XML,because the ZIP stream of a deflated inner file is not seekable — the tail cannot bereached without reading through the whole entry. On wide sheets requesting columns($countColumns = true) is significantly more expensive than rows only, since everycell tag must be scanned. Prefer dimension() when the declared range is enough.
Parameters
bool $countColumnsbool $countRowsint $blockSize
countActualRows()
public function countActualRows(): int
Returns the actual number of rows from the sheet data area
Parameters
None
countCols()
public function countCols(?string $range = null): int
Count columns by dimension value, alias of countColumns()
Parameters
string|null $range
countColumns()
public function countColumns(?string $range = null): int
Count columns by dimension value
Parameters
string|null $range
countImages()
public function countImages(): int
Count images of the sheet
Parameters
None
countRows()
public function countRows(?string $range = null): int
Count rows by dimension value
Parameters
string|null $range
dimension()
public function dimension(): ?string
Get sheet dimension range (e.g. "A1:C10")
Parameters
None
dimensionArray()
public function dimensionArray(): array
Get sheet dimension as an array
Parameters
None
extractConditionalFormatting()
public function extractConditionalFormatting(): void
Extracts conditional formatting rules from the sheet
Parameters
None
extractDataValidations()
public function extractDataValidations(): void
Extracts data validation rules from the sheet
Parameters
None
extractHyperlinks()
public function extractHyperlinks(): void
Extracts the
Parameters
None
firstCol()
public function firstCol(): string
Get letter of the first column in the read area
Parameters
None
firstRow()
public function firstRow(): int
Get number of the first row in the read area
Parameters
None
from()
public function from(string $topLeftCell,
?bool $firstRowKeys = false): AbstractSheet
Set top left of read area. Alias of setReadArea()
Parameters
string $topLeftCellbool|null $firstRowKeys
getAllColAttributes()
public function getAllColAttributes(): array
Get all column attributes
Parameters
None
getAllRowAttributes()
public function getAllRowAttributes(): array
Read all row attributes to the array
Parameters
None
getColumnAttributes()
public function getColumnAttributes($col): array|mixed
Get column attributes (width, style, etc)
Parameters
int|string $col
getColumnStyle()
public function getColumnStyle($col, ?bool $flat = false): array
Get column style
Parameters
int|string $colbool|null $flat
getColumnWidth()
public function getColumnWidth(int $colNumber): ?float
Get width of the column
Parameters
int|string $colNumber
getConditionalFormatting()
public function getConditionalFormatting(): array
Get conditional formatting rules
Parameters
None
getDataValidations()
public function getDataValidations(): array
Get data validation rules
Parameters
None
getFreezePaneInfo()
public function getFreezePaneInfo(): ?array
Get freeze pane info
Parameters
None
getHyperlinks()
public function getHyperlinks(): array
Get cell hyperlinks, keyed by the cell (or range) they are anchored to
Each entry is ['link' => string, 'location' => string, 'display' => string, 'tooltip' => string] where 'link' is the resolved external target (the URL from the sheet relationships), and 'location' is the in-document location - a cell reference like 'Sheet2!A1' for an internal link, or a fragment appended to an external target. Absent attributes are returned as empty strings.
Parameters
None
getImageBlob()
public function getImageBlob(string $cell): ?string
Get image content as binary string
Parameters
string $cell
getImageList()
public function getImageList(): array
Get image list
Parameters
None
getImageListByRow()
public function getImageListByRow($row): array
Get image list by row number
Parameters
$row
getImageMimeType()
public function getImageMimeType(string $cell): ?string
Get image MIME typeRequires fileinfo extension
Parameters
string $cell
getImageName()
public function getImageName(string $cell): ?string
Get image name
Parameters
string $cell
getMergedCells()
public function getMergedCells(): ?array
Get merged cells. Returns an array [min_cell => range]
Note: merge definitions live after <sheetData>, so the first call reads the sheet XMLthrough to the end (result is cached). Lazy — only triggered when merged data is requested.
Parameters
None
getReadRowNum()
public function getReadRowNum(): int
Get the number of the last row read
Parameters
None
getRowAttributes()
public function getRowAttributes(int $row): array
Get row attributes (height, style, etc)
Parameters
int $row
getRowHeight()
public function getRowHeight(int $rowNumber): ?float
Get height of the row
Parameters
int $rowNumber
getRowStyle()
public function getRowStyle(int $row, ?bool $flat = false): array
Get row style
Parameters
int $rowbool|null $flat
getTabColorConfiguration()
public function getTabColorConfiguration(): ?array
Get tab color configuration. Alias of getTabColorConfig()
Parameters
None
getTabColorInfo()
public function getTabColorInfo(): ?array
Get the tab color info of the sheetContains any of: rgb, theme, tint, indexed
Parameters
None
hasDrawings()
public function hasDrawings(): bool
Returns true if the sheet has drawings
Parameters
None
hasImage()
public function hasImage(string $cell): bool
Returns TRUE if the cell contains an image
Parameters
string $cell
id()
public function id(): string
Get sheet ID
Parameters
None
imageEntryFullPath()
public function imageEntryFullPath(string $cell): ?string
Get full path to the image in the ZIP archive
Parameters
string $cell
isActive()
public function isActive(): bool
Returns true if the sheet is active
Parameters
None
isHidden()
public function isHidden(): bool
Returns true if the sheet is hidden
Parameters
None
isMerged()
public function isMerged(string $cellAddress): bool
Returns true if the cell is merged
Parameters
string $cellAddress
isName()
public function isName(string $name): bool
Case-insensitive name checking
Parameters
string $name
isVisible()
public function isVisible(): bool
Returns true if the sheet is visible
Parameters
None
maxActualColumn()
public function maxActualColumn(): string
Get the last actual column letter
Parameters
None
maxActualRow()
public function maxActualRow(): int
Get the last actual row number
Note: performs a full streaming pass over the sheet (see countActualDimension()).
Parameters
None
maxColumn()
public function maxColumn(?string $range = null): string
Max column from dimension value
Parameters
string|null $range
maxRow()
public function maxRow(?string $range = null): int
Max row number from dimension value
Parameters
string|null $range
mergedRange()
public function mergedRange(string $cellAddress): ?string
Get merged range for the cell
Parameters
string $cellAddress
minActualColumn()
public function minActualColumn(): string
Get the first actual column letter
Parameters
None
minActualRow()
public function minActualRow(): int
Get the first actual row number
Parameters
None
minColumn()
public function minColumn(?string $range = null): string
Min column from dimension value
Parameters
string|null $range
minRow()
public function minRow(?string $range = null): int
Min row number from dimension value
Parameters
string|null $range
name()
public function name(): string
Get sheet name
Parameters
None
nextRow()
public function nextRow($columnKeys, ?int $resultMode = null,
?bool $styleIdxInclude = null,
?int $rowLimit = 0): ?Generator
Read cell values row by row, returns either an array of values or an array of arrays
nextRow(..., ...) : <rowNum> => [<colNum1> =>
Parameters
array|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxIncludeint|null $rowLimit
path()
public function path(): string
Get path to the sheet XML file in ZIP archive
Parameters
None
readCallback()
public function readCallback(callable $callback, $columnKeys,
?int $resultMode = null,
?bool $styleIdxInclude = null)
Reads cell values and passes them to a callback function
Parameters
callback $callback– Callback function($row, $col, $value)array|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxInclude
readCells()
public function readCells(?bool $styleIdxInclude = null): array
Returns values and styles of cells as array
Parameters
bool|null $styleIdxInclude
readCellsFrom()
public function readCellsFrom(string $areaRange,
?bool $styleIdxInclude = null): array
Set read area and returns cell values as a one-dimensional array [address => value]
Parameters
string $areaRangebool|null $styleIdxInclude
readCellStyles()
public function readCellStyles(?bool $flat = false,
?string $part = null): array
Returns styles of cells as array
Parameters
bool|null $flatstring|null $part
readCellsWithStyles()
public function readCellsWithStyles(?string $styleKey = null): array
Returns cell values and styles as a one-dimensional array [address => value]:'v' => value's' => styles'f' => formula't' => type'o' => original_value
Parameters
string|null $styleKey– If specified, only this style property will be returned (e.g. 'fill-color')
readCellsWithStylesFrom()
public function readCellsWithStylesFrom(string $areaRange,
?string $styleKey = null): array
Set read area and returns cell values and styles as a one-dimensional array [address => value]
Parameters
string $areaRangestring|null $styleKey– If specified, only this style property will be returned (e.g. 'fill-color')
readColumns()
public function readColumns($columnKeys, ?int $resultMode = null,
?bool $styleIdxInclude = null): array
Returns cell values as a two-dimensional array from default sheet [col][row]['A' => [1 => value_A1], [2 => value_A2]],['B' => [1 => value_B1], [2 => value_B2]]
Parameters
array|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxInclude
readColumnsFrom()
public function readColumnsFrom(string $areaRange, $columnKeys,
?int $resultMode = null,
?bool $styleIdxInclude = null): array
Set read area and returns cell values as a two-dimensional array from default sheet [col][row]
Parameters
string $areaRangearray|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxInclude
readColumnsWithStyles()
public function readColumnsWithStyles($columnKeys,
?int $resultMode = null): array
Returns cell values and styles as a two-dimensional array [column][row]
Parameters
array|bool|int|null $columnKeysint|null $resultMode
readColumnsWithStylesFrom()
public function readColumnsWithStylesFrom(string $areaRange, $columnKeys,
?int $resultMode = null): array
Set read area and returns cell values and styles as a two-dimensional array [column][row]
Parameters
string $areaRange$columnKeysint|null $resultMode
readFirstRow()
public function readFirstRow($columnKeys,
?bool $styleIdxInclude = null): array
Returns values of cells of 1st row as array
Parameters
array|bool|int|null $columnKeysbool|null $styleIdxInclude
readFirstRowCells()
public function readFirstRowCells(?bool $styleIdxInclude = null): array
Returns values and styles of cells of 1st row as array
Parameters
bool|null $styleIdxInclude
readFirstRowCellsFrom()
public function readFirstRowCellsFrom(string $areaRange,
?bool $styleIdxInclude = null): array
Set read area and returns cell values of 1st row as array [address => value]
Like readCellsFrom(), this method takes no column keys, because the result is keyed by cell address and renaming a column would corrupt it.
Parameters
string $areaRangebool|null $styleIdxInclude
readFirstRowFrom()
public function readFirstRowFrom(string $areaRange, $columnKeys,
?bool $styleIdxInclude = null): array
Set read area and returns values of cells of 1st row as array
Parameters
string $areaRangearray|bool|int|null $columnKeysbool|null $styleIdxInclude
readFirstRowWithStyles()
public function readFirstRowWithStyles($columnKeys): array
Returns values and styles of cells of 1st row as array
Parameters
array|bool|int|null $columnKeys
readFirstRowWithStylesFrom()
public function readFirstRowWithStylesFrom(string $areaRange,
$columnKeys): array
Set read area and returns values and styles of cells of 1st row as array
Parameters
string $areaRangearray|bool|int|null $columnKeys
readNextRow()
public function readNextRow(): mixed
Read the next row from the generator
Parameters
None
readRows()
public function readRows($columnKeys, ?int $resultMode = null,
?bool $styleIdxInclude = null): array
Returns cell values as a two-dimensional array[1 => ['A' => value_A1], ['B' => value_B1]],[2 => ['A' => value_A2], ['B' => value_B2]]
readRows()readRows(true)readRows(false, Excel::KEYS_ZERO_BASED)readRows(Excel::KEYS_ZERO_BASED | Excel::KEYS_RELATIVE)
Parameters
array|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxInclude
readRowsFrom()
public function readRowsFrom(string $areaRange, $columnKeys,
?int $resultMode = null,
?bool $styleIdxInclude = null): array
Read rows from a given area $areaRange
Parameters
string $areaRangearray|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxInclude
readRowsWithStyles()
public function readRowsWithStyles($columnKeys,
?int $resultMode = null): array
Returns values, styles, and other info of cells as array
['v' => value,'s' => styles,'f' => formula,'t' => type,'o' => 'original_value]
Parameters
array|bool|int|null $columnKeysint|null $resultMode
readRowsWithStylesFrom()
public function readRowsWithStylesFrom(string $areaRange, $columnKeys,
?int $resultMode = null): array
Set read area and returns values, styles, and other info of cells as array
Parameters
string $areaRangearray|bool|int|null $columnKeysint|null $resultMode
reset()
public function reset($columnKeys, ?int $resultMode = null,
?bool $styleIdxInclude = null,
?int $rowLimit = 0): ?Generator
Reset read generator
Parameters
array|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxIncludeint|null $rowLimit
rewind()
public function rewind($columnKeys, ?int $resultMode = null,
?bool $styleIdxInclude = null,
?int $rowLimit = 0): ?Generator
Rewind read generator, alias of reset()
Parameters
array|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxIncludeint|null $rowLimit
saveImage()
public function saveImage(string $cell, ?string $filename = null): ?string
Save image to a file
Parameters
string $cellstring|null $filename
saveImageTo()
public function saveImageTo(string $cell, string $dirname): ?string
Save image to a directory
Parameters
string $cellstring $dirname
setDateFormat()
public function setDateFormat($dateFormat): AbstractSheet
Set date format
Parameters
$dateFormat
setDefaultRowHeight()
public function setDefaultRowHeight(float $rowHeight): void
Set default row height
Parameters
float $rowHeight
setReadArea()
public function setReadArea(string $areaRange,
?bool $firstRowKeys = false): AbstractSheet
Set top left and right bottom of read area
Parameters
string $areaRangebool|null $firstRowKeys
Examples
setReadArea('C3:AZ28'); // set top left and right bottom of read area
setReadArea('C3'); // set top left only
setReadAreaColumns()
public function setReadAreaColumns(string $columnsRange,
?bool $firstRowKeys = false): AbstractSheet
setReadArea('C:AZ') - set left and right columns of read areasetReadArea('C') - set left column only
Parameters
string $columnsRangebool|null $firstRowKeys
setState()
public function setState(string $state): AbstractSheet
Set sheet state (visible, hidden, veryHidden)
Parameters
string $state
stat()
public function stat(): array
Returns statistics of the sheet: rows, columns and cell counts
['rows' => ['min' => int, 'max' => int, 'count' => int],'cols' => ['min' => string, 'max' => string, 'count' => int],'cells' => ['total' => int, 'filled' => int],]
Note: performs a full streaming pass over the sheet XML (cached); memory is O(blockSize),but time grows with the number of cells — expensive on large/wide sheets.
Parameters
None
state()
public function state(): string
Get sheet state
Parameters
None
withHeader()
public function withHeader(?array $columnNames = null): AbstractSheet
Enables header mode
Treats the first row of the read area as a header row and returns subsequent rowsas associative arrays keyed by column names.
Pass $columnNames to name the columns yourself: the first row is still skipped,but the names are taken from the list instead of from its values. Names areapplied in column order, starting at the first column of the read area, so theyneed no knowledge of column letters. Columns past the end of the list keep thename from the header row.
Parameters
array|null $columnNames– Column names in order, or NULL to use the header row values