Class \avadim\FastExcelTemplator\SheetTemplate
On this page
- __construct()
- Parameters
- actualDimension()
- Parameters
- cloneRow()
- 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
- fill()
- Parameters
- Examples
- 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
- getRowTemplate()
- Parameters
- Examples
- getRowTemplates()
- Parameters
- Examples
- getTabColorConfiguration()
- Parameters
- getTabColorInfo()
- Parameters
- hasDrawings()
- Parameters
- hasImage()
- Parameters
- hasStructuralChanges()
- Parameters
- id()
- Parameters
- imageEntryFullPath()
- Parameters
- insertRow()
- Parameters
- Examples
- isActive()
- Parameters
- isHidden()
- Parameters
- isMerged()
- Parameters
- isName()
- Parameters
- isVisible()
- Parameters
- lastReadRowNum()
- Parameters
- lastWrittenRowNum()
- 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
- postRead()
- Parameters
- preRead()
- 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
- readRow()
- Parameters
- readRows()
- Parameters
- readRowsFrom()
- Parameters
- readRowsWithStyles()
- Parameters
- readRowsWithStylesFrom()
- Parameters
- replace()
- Parameters
- Examples
- replaceRow()
- Parameters
- reset()
- Parameters
- rewind()
- Parameters
- rows()
- Parameters
- Examples
- saveImage()
- Parameters
- saveImageTo()
- Parameters
- saveSheet()
- Parameters
- setDateFormat()
- Parameters
- setDefaultRowHeight()
- Parameters
- setReadArea()
- Parameters
- Examples
- setReadAreaColumns()
- Parameters
- setState()
- Parameters
- skipRows()
- Parameters
- skipRowsUntil()
- Parameters
- stat()
- Parameters
- state()
- Parameters
- transferRows()
- Parameters
- transferRowsUntil()
- Parameters
- withHeader()
- Parameters
- writeCell()
- Parameters
- writeRow()
- Parameters
- __construct() – SheetTemplate constructor
- actualDimension() – Get the actual dimension range (e.g. "A1:C10")
- cloneRow() – Clone current row
- 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 - fill() – Replace the entire cell value: applies only when the whole cell equals the key ('{{X}}', not 'text {{X}}').
- 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
- getRowTemplate() – Capture a source row as a reusable template; returns a collection (use it with insertRow()).
- getRowTemplates() – Capture source rows as templates; missing rows become empty templates, and insertRow() cycles independently of foreach.
- 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
- hasStructuralChanges() – Return the conservative structural-operation flag; range remapping is not verified and direct low-level Writer edits are not fully tracked.
- id() – Get sheet ID
- imageEntryFullPath() – Get full path to the image in the ZIP archive
- insertRow() – Insert a template copy filled by column letter; omitted columns retain template values, and the template and prior inserts remain unchanged.
- 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
- lastReadRowNum() – Last read row number
- lastWrittenRowNum() – Last written row number
- 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 in ZIP
- postRead() – Internal post-read handler
- preRead() – Internal pre-read handler
- 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
- readRow() – Returns the next row from template
- 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
- replace() – Replace a substring inside cell values: the key is matched anywhere in the text ('Date: {{DATE}}' works).
- replaceRow() – Replace row with data
- reset() – Reset read generator
- rewind() – Rewind read generator, alias of reset()
- rows() – Walk all source rows through a callback and write the result (read-modify-write over the whole sheet).
- saveImage() – Save image to a file
- saveImageTo() – Save image to a directory
- saveSheet() – Empty method for compatibility
- 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)
- skipRows() – Skip rows from the template
- skipRowsUntil() – Advance through an inclusive source boundary without writing; later existing rows in a sparse sheet remain available.
- stat() – Returns statistics of the sheet: rows, columns and cell counts
- state() – Get sheet state
- transferRows() – Copy the next $countRows source rows (or all remaining if null) to the output, with an optional callback.
- transferRowsUntil() – Copy source rows to the output up to $maxRowNum; an optional callback can modify, skip or stop each row.
- withHeader() – Enables header mode
- writeCell() – Write value to the current cell and move a pointer to the next cell in the row
- writeRow() – Write values to the current row
__construct()
public function __construct(string $sheetName, string $sheetId, string $file,
string $path, $excel)
SheetTemplate constructor
Parameters
string $sheetNamestring $sheetIdstring $filestring $pathExcel $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
cloneRow()
public function cloneRow(?array $cellData = []): $this
Clone current row
Parameters
array|null $cellData
countActualColumns()
public function countActualColumns(): int
Returns the actual number of columns from the sheet data areaNote: 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 columnsNote: 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
fill()
public function fill(array $params): SheetTemplate
Replace the entire cell value: applies only when the whole cell equals the key ('{{X}}', not 'text {{X}}').
Parameters
array $params– Map of [placeholder => value]; applied to every cell written to the output
Examples
$sheet->fill(['{{COMPANY}}' => 'ACME Inc.', '{{NUMBER}}' => 128]);
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): avadim\FastExcelReader\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 toEach entry is['link' => string, 'location' => string, 'display' => string, 'tooltip' => string]where 'link' is the resolved external target (the URL from the sheetrelationships), and 'location' is the in-document location - a cellreference like 'Sheet2!A1' for an internal link, or a fragment appended toan 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
getRowTemplate()
public function getRowTemplate(int $rowNumber,
?bool $savePointerPosition = false): RowTemplateCollection
Capture a source row as a reusable template; returns a collection (use it with insertRow()).
Parameters
int $rowNumber– Source row number to capturebool|null $savePointerPosition– If false (default), the read cursor is advanced to this row
Examples
$tpl = $sheet->getRowTemplate(7);
foreach ($data as $row) { $sheet->insertRow($tpl, ['A' => $row['id']]); }
getRowTemplates()
public function getRowTemplates(int $rowNumberMin, int $rowNumberMax,
?bool $savePointerPosition = false): RowTemplateCollection
Capture source rows as templates; missing rows become empty templates, and insertRow() cycles independently of foreach.
Parameters
int $rowNumberMin– First source row of the rangeint $rowNumberMax– Last source row of the rangebool|null $savePointerPosition– If false (default), the read cursor is advanced to $rowNumberMax
Examples
$tpls = $sheet->getRowTemplates(7, 8); // two styles, alternated on each insertRow()
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
hasStructuralChanges()
public function hasStructuralChanges(): bool
Return the conservative structural-operation flag; range remapping is not verified and direct low-level Writer edits are not fully tracked.
Parameters
None
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
insertRow()
public function insertRow($row, ?array $cellData = []): SheetTemplate
Insert a template copy filled by column letter; omitted columns retain template values, and the template and prior inserts remain unchanged.
Parameters
array|RowTemplateCollection|RowTemplate $row– A template (or collection to cycle through), or a plain [col => value] array for a blank rowarray|null $cellData– Values keyed by column letter, e.g. ['A' => 1, 'B' => 'name']
Examples
$sheet->insertRow($rowTemplate, ['A' => $item['id'], 'B' => $item['name']]);
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
lastReadRowNum()
public function lastReadRowNum(): int
Last read row number
Parameters
None
lastWrittenRowNum()
public function lastWrittenRowNum(): int
Last written row number
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 numberNote: 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 arraysnextRow(..., ...) : <rowNum> => [<colNum1> =>
Parameters
array|bool|int|null $columnKeysint|null $resultModebool|null $styleIdxIncludeint|null $rowLimit
path()
public function path(): string
Get path in ZIP
Parameters
None
postRead()
public function postRead($xmlReader)
Internal post-read handler
Parameters
\XMLReader $xmlReader
preRead()
public function preRead($xmlReader)
Internal pre-read handler
Parameters
\XMLReader $xmlReader
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
readRow()
public function readRow(): ?Generator
Returns the next row from template
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
replace()
public function replace(array $params): SheetTemplate
Replace a substring inside cell values: the key is matched anywhere in the text ('Date: {{DATE}}' works).
Parameters
array $params– Map of [search => replacement]; applied to every cell written to the output
Examples
$sheet->replace(['{{DATE}}' => date('d.m.Y')]);
replaceRow()
public function replaceRow($row, ?array $cellData = []): $this
Replace row with data
Parameters
mixed $rowarray|null $cellData
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
rows()
public function rows($callback): SheetTemplate
Walk all source rows through a callback and write the result (read-modify-write over the whole sheet).
Parameters
callable $callback– function($sourceRowNum, $targetRowNum, RowTemplate $row): return $row to write it, null to skip the row, false to stop
Examples
$sheet->rows(function ($src, $dst, $row) {
if ($src === 1) return $row; // keep header
$row->setValue('C', $row->getValue('C') * 1.2);
return $row;
});
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
saveSheet()
public function saveSheet(): void
Empty method for compatibility
Parameters
None
setDateFormat()
public function setDateFormat($dateFormat): avadim\FastExcelReader\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): avadim\FastExcelReader\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): avadim\FastExcelReader\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): avadim\FastExcelReader\AbstractSheet
Set sheet state (visible, hidden, veryHidden)
Parameters
string $state
skipRows()
public function skipRows(?int $countRows = null): SheetTemplate
Skip rows from the template
Parameters
int|null $countRows– Source row positions to skip; null means to EOF, zero is a no-op, negative counts throw Exception
skipRowsUntil()
public function skipRowsUntil(?int $maxRowNum = null): SheetTemplate
Advance through an inclusive source boundary without writing; later existing rows in a sparse sheet remain available.
Parameters
int|null $maxRowNum– Inclusive source boundary; null means to EOF, zero is a no-op, negative values throw Exception
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
transferRows()
public function transferRows(?int $countRows = null, $callback): SheetTemplate
Copy the next $countRows source rows (or all remaining if null) to the output, with an optional callback.
Parameters
int|null $countRows– Source row positions to transfer; null means to EOF, zero is a no-op, negative counts throw Exceptioncallable|null $callback– function($sourceRowNum, $targetRowNum, RowTemplate $row): return $row to write it, null to skip the row, false to stop
transferRowsUntil()
public function transferRowsUntil(?int $maxRowNum = null,
$callback): SheetTemplate
Copy source rows to the output up to $maxRowNum; an optional callback can modify, skip or stop each row.
Parameters
int|null $maxRowNum– Inclusive source boundary; null means to EOF, zero is a no-op, negative values throw Exceptioncallable|null $callback– function($sourceRowNum, $targetRowNum, RowTemplate $row): return $row to write it, null to skip the row, false to stop
withHeader()
public function withHeader(?array $columnNames = null): avadim\FastExcelReader\AbstractSheet
Enables header modeTreats 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
writeCell()
public function writeCell($value, ?array $styles = null): SheetTemplate
Write value to the current cell and move a pointer to the next cell in the row
Parameters
mixed $valuearray|null $styles
writeRow()
public function writeRow(array $rowValues = [], ?array $rowStyle = null,
?array $cellStyles = null): SheetTemplate
Write values to the current row
Parameters
array $rowValues– Values of cellsarray|null $rowStyle– Style applied to the entire rowarray|null $cellStyles– Styles of specified cells in the row