Class \avadim\FastExcelReader\Sheet

Source: 4.5.0 · dd0d48d

On this page


__construct()


php
public function __construct(string $sheetName, string $sheetId, string $file, 
                            string $path, $excel)

Parameters

  • string $sheetName
  • string $sheetId
  • string $file
  • string $path
  • $excel

actualDimension()


php
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()


php
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()


php
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 $countColumns
  • bool $countRows
  • int $blockSize

countActualRows()


php
public function countActualRows(): int

Returns the actual number of rows from the sheet data area

Parameters

None


countCols()


php
public function countCols(?string $range = null): int

Count columns by dimension value, alias of countColumns()

Parameters

  • string|null $range

countColumns()


php
public function countColumns(?string $range = null): int

Count columns by dimension value

Parameters

  • string|null $range

countImages()


php
public function countImages(): int

Count images of the sheet

Parameters

None


countRows()


php
public function countRows(?string $range = null): int

Count rows by dimension value

Parameters

  • string|null $range

dimension()


php
public function dimension(): ?string

Get sheet dimension range (e.g. "A1:C10")

Parameters

None


dimensionArray()


php
public function dimensionArray(): array

Get sheet dimension as an array

Parameters

None


extractConditionalFormatting()


php
public function extractConditionalFormatting(): void

Extracts conditional formatting rules from the sheet

Parameters

None


extractDataValidations()


php
public function extractDataValidations(): void

Extracts data validation rules from the sheet

Parameters

None


extractHyperlinks()


php
public function extractHyperlinks(): void

Extracts the section of the sheet and resolves external targets from the sheet relationships file

Parameters

None


firstCol()


php
public function firstCol(): string

Get letter of the first column in the read area

Parameters

None


firstRow()


php
public function firstRow(): int

Get number of the first row in the read area

Parameters

None


from()


php
public function from(string $topLeftCell, 
                     ?bool $firstRowKeys = false): AbstractSheet

Set top left of read area. Alias of setReadArea()

Parameters

  • string $topLeftCell
  • bool|null $firstRowKeys

getAllColAttributes()


php
public function getAllColAttributes(): array

Get all column attributes

Parameters

None


getAllRowAttributes()


php
public function getAllRowAttributes(): array

Read all row attributes to the array

Parameters

None


getColumnAttributes()


php
public function getColumnAttributes($col): array|mixed

Get column attributes (width, style, etc)

Parameters

  • int|string $col

getColumnStyle()


php
public function getColumnStyle($col, ?bool $flat = false): array

Get column style

Parameters

  • int|string $col
  • bool|null $flat

getColumnWidth()


php
public function getColumnWidth(int $colNumber): ?float

Get width of the column

Parameters

  • int|string $colNumber

getConditionalFormatting()


php
public function getConditionalFormatting(): array

Get conditional formatting rules

Parameters

None


getDataValidations()


php
public function getDataValidations(): array

Get data validation rules

Parameters

None


getFreezePaneInfo()


php
public function getFreezePaneInfo(): ?array

Get freeze pane info

Parameters

None


getHyperlinks()


php
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()


php
public function getImageBlob(string $cell): ?string

Get image content as binary string

Parameters

  • string $cell

getImageList()


php
public function getImageList(): array

Get image list

Parameters

None


getImageListByRow()


php
public function getImageListByRow($row): array

Get image list by row number

Parameters

  • $row

getImageMimeType()


php
public function getImageMimeType(string $cell): ?string

Get image MIME typeRequires fileinfo extension

Parameters

  • string $cell

getImageName()


php
public function getImageName(string $cell): ?string

Get image name

Parameters

  • string $cell

getMergedCells()


php
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()


php
public function getReadRowNum(): int

Get the number of the last row read

Parameters

None


getRowAttributes()


php
public function getRowAttributes(int $row): array

Get row attributes (height, style, etc)

Parameters

  • int $row

getRowHeight()


php
public function getRowHeight(int $rowNumber): ?float

Get height of the row

Parameters

  • int $rowNumber

getRowStyle()


php
public function getRowStyle(int $row, ?bool $flat = false): array

Get row style

Parameters

  • int $row
  • bool|null $flat

getTabColorConfiguration()


php
public function getTabColorConfiguration(): ?array

Get tab color configuration. Alias of getTabColorConfig()

Parameters

None


getTabColorInfo()


php
public function getTabColorInfo(): ?array

Get the tab color info of the sheetContains any of: rgb, theme, tint, indexed

Parameters

None


hasDrawings()


php
public function hasDrawings(): bool

Returns true if the sheet has drawings

Parameters

None


hasImage()


php
public function hasImage(string $cell): bool

Returns TRUE if the cell contains an image

Parameters

  • string $cell

id()


php
public function id(): string

Get sheet ID

Parameters

None


imageEntryFullPath()


php
public function imageEntryFullPath(string $cell): ?string

Get full path to the image in the ZIP archive

Parameters

  • string $cell

isActive()


php
public function isActive(): bool

Returns true if the sheet is active

Parameters

None


isHidden()


php
public function isHidden(): bool

Returns true if the sheet is hidden

Parameters

None


isMerged()


php
public function isMerged(string $cellAddress): bool

Returns true if the cell is merged

Parameters

  • string $cellAddress

isName()


php
public function isName(string $name): bool

Case-insensitive name checking

Parameters

  • string $name

isVisible()


php
public function isVisible(): bool

Returns true if the sheet is visible

Parameters

None


maxActualColumn()


php
public function maxActualColumn(): string

Get the last actual column letter

Parameters

None


maxActualRow()


php
public function maxActualRow(): int

Get the last actual row number

Note: performs a full streaming pass over the sheet (see countActualDimension()).

Parameters

None


maxColumn()


php
public function maxColumn(?string $range = null): string

Max column from dimension value

Parameters

  • string|null $range

maxRow()


php
public function maxRow(?string $range = null): int

Max row number from dimension value

Parameters

  • string|null $range

mergedRange()


php
public function mergedRange(string $cellAddress): ?string

Get merged range for the cell

Parameters

  • string $cellAddress

minActualColumn()


php
public function minActualColumn(): string

Get the first actual column letter

Parameters

None


minActualRow()


php
public function minActualRow(): int

Get the first actual row number

Parameters

None


minColumn()


php
public function minColumn(?string $range = null): string

Min column from dimension value

Parameters

  • string|null $range

minRow()


php
public function minRow(?string $range = null): int

Min row number from dimension value

Parameters

  • string|null $range

name()


php
public function name(): string

Get sheet name

Parameters

None


nextRow()


php
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> => , <colNum2> => , ...]nextRow(..., ..., true) : <rowNum> => [<colNum1> => ['v' => , 's' => ], <colNum2> => ['v' => , 's' => ], ...]

Parameters

  • array|bool|int|null $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude
  • int|null $rowLimit

path()


php
public function path(): string

Get path to the sheet XML file in ZIP archive

Parameters

None


readCallback()


php
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 $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude

readCells()


php
public function readCells(?bool $styleIdxInclude = null): array

Returns values and styles of cells as array

Parameters

  • bool|null $styleIdxInclude

readCellsFrom()


php
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 $areaRange
  • bool|null $styleIdxInclude

readCellStyles()


php
public function readCellStyles(?bool $flat = false, 
                               ?string $part = null): array

Returns styles of cells as array

Parameters

  • bool|null $flat
  • string|null $part

readCellsWithStyles()


php
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()


php
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 $areaRange
  • string|null $styleKey – If specified, only this style property will be returned (e.g. 'fill-color')

readColumns()


php
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 $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude

readColumnsFrom()


php
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 $areaRange
  • array|bool|int|null $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude

readColumnsWithStyles()


php
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 $columnKeys
  • int|null $resultMode

readColumnsWithStylesFrom()


php
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
  • $columnKeys
  • int|null $resultMode

readFirstRow()


php
public function readFirstRow($columnKeys, 
                             ?bool $styleIdxInclude = null): array

Returns values of cells of 1st row as array

Parameters

  • array|bool|int|null $columnKeys
  • bool|null $styleIdxInclude

readFirstRowCells()


php
public function readFirstRowCells(?bool $styleIdxInclude = null): array

Returns values and styles of cells of 1st row as array

Parameters

  • bool|null $styleIdxInclude

readFirstRowCellsFrom()


php
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 $areaRange
  • bool|null $styleIdxInclude

readFirstRowFrom()


php
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 $areaRange
  • array|bool|int|null $columnKeys
  • bool|null $styleIdxInclude

readFirstRowWithStyles()


php
public function readFirstRowWithStyles($columnKeys): array

Returns values and styles of cells of 1st row as array

Parameters

  • array|bool|int|null $columnKeys

readFirstRowWithStylesFrom()


php
public function readFirstRowWithStylesFrom(string $areaRange, 
                                           $columnKeys): array

Set read area and returns values and styles of cells of 1st row as array

Parameters

  • string $areaRange
  • array|bool|int|null $columnKeys

readNextRow()


php
public function readNextRow(): mixed

Read the next row from the generator

Parameters

None


readRows()


php
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 $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude

readRowsFrom()


php
public function readRowsFrom(string $areaRange, $columnKeys, 
                             ?int $resultMode = null, 
                             ?bool $styleIdxInclude = null): array

Read rows from a given area $areaRange

Parameters

  • string $areaRange
  • array|bool|int|null $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude

readRowsWithStyles()


php
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 $columnKeys
  • int|null $resultMode

readRowsWithStylesFrom()


php
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 $areaRange
  • array|bool|int|null $columnKeys
  • int|null $resultMode

reset()


php
public function reset($columnKeys, ?int $resultMode = null, 
                      ?bool $styleIdxInclude = null, 
                      ?int $rowLimit = 0): ?Generator

Reset read generator

Parameters

  • array|bool|int|null $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude
  • int|null $rowLimit

rewind()


php
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 $columnKeys
  • int|null $resultMode
  • bool|null $styleIdxInclude
  • int|null $rowLimit

saveImage()


php
public function saveImage(string $cell, ?string $filename = null): ?string

Save image to a file

Parameters

  • string $cell
  • string|null $filename

saveImageTo()


php
public function saveImageTo(string $cell, string $dirname): ?string

Save image to a directory

Parameters

  • string $cell
  • string $dirname

setDateFormat()


php
public function setDateFormat($dateFormat): AbstractSheet

Set date format

Parameters

  • $dateFormat

setDefaultRowHeight()


php
public function setDefaultRowHeight(float $rowHeight): void

Set default row height

Parameters

  • float $rowHeight

setReadArea()


php
public function setReadArea(string $areaRange, 
                            ?bool $firstRowKeys = false): AbstractSheet

Set top left and right bottom of read area

Parameters

  • string $areaRange
  • bool|null $firstRowKeys

Examples

php
setReadArea('C3:AZ28'); // set top left and right bottom of read area
setReadArea('C3'); // set top left only

setReadAreaColumns()


php
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 $columnsRange
  • bool|null $firstRowKeys

setState()


php
public function setState(string $state): AbstractSheet

Set sheet state (visible, hidden, veryHidden)

Parameters

  • string $state

stat()


php
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()


php
public function state(): string

Get sheet state

Parameters

None


withHeader()


php
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

FastExcelReader 4.5.0 · Search this library and version.

Loading search…

Could not load search. Please try again.

No results. Try another word or method name.