Class \avadim\FastExcelWriter\Excel
On this page
- __construct()
- Parameters
- cellAddress()
- Parameters
- Examples
- colIndex()
- Parameters
- colIndexRange()
- Parameters
- colLetter()
- Parameters
- colLetterRange()
- Parameters
- Examples
- colNumber()
- Parameters
- colNumberRange()
- Parameters
- create()
- Parameters
- createSheet()
- Parameters
- fullAddress()
- Parameters
- generateUuid()
- Parameters
- newStyle()
- Parameters
- pixelsToEMU()
- Parameters
- rangeRelOffsets()
- Parameters
- setTempDir()
- Parameters
- toTimestamp()
- Parameters
- addDefinedName()
- Parameters
- addNamedRange()
- Parameters
- addSharedString()
- Parameters
- download()
- Parameters
- getDefaultFormatStyles()
- Parameters
- getDefaultSheetName()
- Parameters
- getDefaultStyle()
- Parameters
- getDefinedNames()
- Parameters
- getFileName()
- Parameters
- getImageFiles()
- Parameters
- getMetadata()
- Parameters
- getSharedStrings()
- Parameters
- getSheet()
- Parameters
- getSheets()
- Parameters
- getStyleCellStyles()
- Parameters
- getStyleCellStyleXfs()
- Parameters
- getStyleTableStyles()
- Parameters
- getWriter()
- Parameters
- isR1C1()
- Parameters
- isRightToLeft()
- Parameters
- makeSheet()
- Parameters
- output()
- Parameters
- protect()
- Parameters
- removeSheet()
- Parameters
- save()
- Parameters
- setActiveSheet()
- Parameters
- setAuthor()
- Parameters
- setCompany()
- Parameters
- setDefaultFont()
- Parameters
- setDefaultFontName()
- Parameters
- setDefaultLocale()
- Parameters
- setDefaultStyle()
- Parameters
- setDescription()
- Parameters
- setFileName()
- Parameters
- setKeywords()
- Parameters
- setLocale()
- Parameters
- setMetaAuthor()
- Parameters
- setMetaCompany()
- Parameters
- setMetadata()
- Parameters
- setMetaDescription()
- Parameters
- setMetaKeywords()
- Parameters
- setMetaSubject()
- Parameters
- setMetaTitle()
- Parameters
- setR1C1()
- Parameters
- setRightToLeft()
- Parameters
- setSharedString()
- Parameters
- setSubject()
- Parameters
- setTitle()
- Parameters
- sheet()
- Parameters
- unprotect()
- Parameters
- __construct() – Excel constructor
- cellAddress() – Create cell address by row and col numbers
- colIndex() – Convert letter to index (ZERO based)
- colIndexRange() – Convert letter range to array of numbers (ZERO based)
- colLetter() – Convert column number to letter
- colLetterRange() – Convert values to letters array
- colNumber() – Convert letter to number (ONE based)
- colNumberRange() – Convert letter range to array of numbers (ONE based)
- create() – Create a new workbook
- createSheet() – Creates a new sheet
- fullAddress() – Get full address with sheet name
- generateUuid() – Generate UUID v4
- newStyle() – Create a new instance of Style class
- pixelsToEMU() – Convert pixels to EMU (English Metric Units)
- rangeRelOffsets() – Return offsets by relative address (zero based)
- setTempDir() – Set dir for temporary files
- toTimestamp() – Convert value (int or string) to Excel timestamp
- addDefinedName() – Add a defined name
- addNamedRange() – Add a named range
- addSharedString() – Add a string to the shared strings table
- download() – Download generated file to client (send to browser)
- getDefaultFormatStyles() – Get default format styles
- getDefaultSheetName() – Get the default sheet name
- getDefaultStyle() – Get default style
- getDefinedNames() – Get all defined names
- getFileName() – Returns default filename
- getImageFiles() – Get list of all loaded image files
- getMetadata() – Get metadata
- getSharedStrings() – Get the shared strings table
- getSheet() – Alias of sheet()
- getSheets() – Returns all sheets
- getStyleCellStyles()
- getStyleCellStyleXfs()
- getStyleTableStyles()
- getWriter() – Get the writer instance
- isR1C1() – Is R1C1 notation mode enabled?
- isRightToLeft() – Get right-to-left orientation
- makeSheet() – Creates and returns a new sheet
- output() – Alias of download()
- protect() – Protect workbook
- removeSheet() – Removes sheet by index or name of sheet.
- save() – Save generated XLSX-file
- setActiveSheet() – Set active (default) sheet by case-insensitive name
- setAuthor() – Set the author of the document
- setCompany() – Set the company of the document
- setDefaultFont() – Set default font options
- setDefaultFontName() – Set default font name
- setDefaultLocale() – Set default locale from the current environment
- setDefaultStyle() – Set default style
- setDescription() – Set the description of the document
- setFileName() – Sets default filename for saving
- setKeywords() – Set the keywords of the document
- setLocale() – Set locale information
- setMetaAuthor() – Set metadata 'author'
- setMetaCompany() – Set metadata 'company'
- setMetadata() – Set metadata
- setMetaDescription() – Set metadata 'description'
- setMetaKeywords() – Set metadata 'keywords'
- setMetaSubject() – Set metadata 'subject'
- setMetaTitle() – Set metadata 'title'
- setR1C1() – Set R1C1 notation mode
- setRightToLeft() – Set right-to-left orientation
- setSharedString() – Set the usage of shared strings
- setSubject() – Set the subject of the document
- setTitle() – Set the title of the document
- sheet() – Returns sheet by number or name
- unprotect() – Unprotect workbook
__construct()
public function __construct($options)
Excel constructor
Parameters
array|Options|null $options– Optional parameters: ['temp_dir' => ..., 'temp_prefix' => ..., 'auto_convert_number' => ..., 'shared_string' => ...]
cellAddress()
public static function cellAddress(int $rowNumber, int $colNumber,
?bool $absolute = false,
?bool $absoluteRow = null): string
Create cell address by row and col numbers
Parameters
int $rowNumber– ONE basedint $colNumber– ONE basedbool|null $absolutebool|null $absoluteRow
Examples
cellAddress(3, 3) => 'C3'
cellAddress(43, 27) => 'AA43'
cellAddress(43, 27, true) => '$AA$43'
cellAddress(43, 27, false, true) => 'AA$43'
colIndex()
public static function colIndex(string $colLetter): int
Convert letter to index (ZERO based)
Parameters
string $colLetter
colIndexRange()
public static function colIndexRange($colLetter): array
Convert letter range to array of numbers (ZERO based)
Parameters
string|int|array $colLetter– e.g.: 'B', 2, 'C:F', ['A', 'B', 'C']
colLetter()
public static function colLetter(int $colNumber): string
Convert column number to letter
Parameters
int $colNumber– ONE based
colLetterRange()
public static function colLetterRange($colKeys, ?int $baseNum = 0): array
Convert values to letters array
Parameters
array|string $colKeysint|null $baseNum– 0 or 1
Examples
$res = colLetterRange([0, 1, 2]); // returns ['A', 'B', 'C']
$res = colLetterRange([1, 2, 3], 1); // returns ['A', 'B', 'C']
$res = colLetterRange('B, E, F'); // returns ['B', 'E', 'F']
$res = colLetterRange('B-E, F'); // returns ['B', 'C', 'D', 'E', 'F']
$res = colLetterRange('B1-E8'); // returns ['B', 'C', 'D', 'E']
$res = colLetterRange('B1:E8'); // returns ['B:E']
colNumber()
public static function colNumber(string $colLetter): int
Convert letter to number (ONE based)
Parameters
string $colLetter
colNumberRange()
public static function colNumberRange($colLetter): array
Convert letter range to array of numbers (ONE based)
Parameters
string|int|array $colLetter– e.g.: 'B', 2, 'C:F', ['A', 'B', 'C']
create()
public static function create($sheets, $options): Excel
Create a new workbook
Parameters
array|string|null $sheets– Name of sheet or array of namesarray|Options|null $options– Options
createSheet()
public static function createSheet(string $sheetName): Sheet
Creates a new sheet
Parameters
string $sheetName
fullAddress()
public static function fullAddress(string $sheetName, string $address,
?bool $force = false): string
Get full address with sheet name
Parameters
string $sheetNamestring $addressbool|null $force
generateUuid()
public static function generateUuid(): string
Generate UUID v4
Parameters
None
newStyle()
public static function newStyle(): Style\Style
Create a new instance of Style class
Parameters
None
pixelsToEMU()
public static function pixelsToEMU($pixels): float|int
Convert pixels to EMU (English Metric Units)
Parameters
int|float $pixels
rangeRelOffsets()
public static function rangeRelOffsets(string $relAddress): array
Return offsets by relative address (zero based)
Parameters
string $relAddress
setTempDir()
public static function setTempDir($tempDir)
Set dir for temporary files
Parameters
$tempDir
toTimestamp()
public static function toTimestamp($value): float|bool
Convert value (int or string) to Excel timestamp
Parameters
int|string $value
addDefinedName()
public function addDefinedName(string $name, string $range,
?array $attributes = []): Excel
Add a defined name
Parameters
string $namestring $rangearray|null $attributes
addNamedRange()
public function addNamedRange(string $range, string $name): Excel
Add a named range
Parameters
string $rangestring $name
addSharedString()
public function addSharedString(string $string, ?bool $richText = false): int
Add a string to the shared strings table
Parameters
string $stringbool|null $richText
download()
public function download(?string $name = null)
Download generated file to client (send to browser)
Parameters
string|null $name
getDefaultFormatStyles()
public function getDefaultFormatStyles(): array
Get default format styles
Parameters
None
getDefaultSheetName()
public function getDefaultSheetName(): string
Get the default sheet name
Parameters
None
getDefaultStyle()
public function getDefaultStyle(): array
Get default style
Parameters
None
getDefinedNames()
public function getDefinedNames(): array
Get all defined names
Parameters
None
getFileName()
public function getFileName(): string
Returns default filename
Parameters
None
getImageFiles()
public function getImageFiles(): array
Get list of all loaded image files
Parameters
None
getMetadata()
public function getMetadata($key): mixed
Get metadata
Parameters
null $key
getSharedStrings()
public function getSharedStrings(): array
Get the shared strings table
Parameters
None
getSheet()
public function getSheet($index): ?Sheet
Alias of sheet()
Parameters
int|string|null $index– - number or name of sheet
getSheets()
public function getSheets(): array
Returns all sheets
Parameters
None
getStyleCellStyles()
public function getStyleCellStyles(): array
Parameters
None
getStyleCellStyleXfs()
public function getStyleCellStyleXfs(): array
Parameters
None
getStyleTableStyles()
public function getStyleTableStyles(): array
Parameters
None
getWriter()
public function getWriter(): Writer
Get the writer instance
Parameters
None
isR1C1()
public function isR1C1(): bool
Is R1C1 notation mode enabled?
Parameters
None
isRightToLeft()
public function isRightToLeft(): bool
Get right-to-left orientation
Parameters
None
makeSheet()
public function makeSheet(?string $sheetName = null): Sheet
Creates and returns a new sheet
Parameters
string|null $sheetName
output()
public function output(?string $name = null): void
Alias of download()
Parameters
string|null $name
protect()
public function protect(?string $password = null): Excel
Protect workbook
Parameters
string|null $password
removeSheet()
public function removeSheet($index): Excel
Removes sheet by index or name of sheet.Removes the first sheet of index omitted
Parameters
int|string|null $index
save()
public function save(?string $fileName = null, ?bool $overWrite = true): bool
Save generated XLSX-file
Parameters
string|null $fileNamebool|null $overWrite
setActiveSheet()
public function setActiveSheet(string $name): Excel
Set active (default) sheet by case-insensitive name
Parameters
string $name
setAuthor()
public function setAuthor(?string $author = ''): Excel
Set the author of the document
Parameters
string|null $author
setCompany()
public function setCompany(?string $company = ''): Excel
Set the company of the document
Parameters
string|null $company
setDefaultFont()
public function setDefaultFont(array $fontOptions): Excel
Set default font options
Parameters
array $fontOptions
setDefaultFontName()
public function setDefaultFontName(string $fontName): Excel
Set default font name
Parameters
string $fontName
setDefaultLocale()
public function setDefaultLocale()
Set default locale from the current environment
Parameters
None
setDefaultStyle()
public function setDefaultStyle(array $style): Excel
Set default style
Parameters
array $style
setDescription()
public function setDescription(?string $description = ''): Excel
Set the description of the document
Parameters
string|null $description
setFileName()
public function setFileName(string $fileName): Excel
Sets default filename for saving
Parameters
string $fileName
setKeywords()
public function setKeywords($keywords): Excel
Set the keywords of the document
Parameters
string|array $keywords
setLocale()
public function setLocale(string $locale, ?string $dir = null): Excel
Set locale information
Parameters
string $localestring|null $dir
setMetaAuthor()
public function setMetaAuthor(?string $author = ''): Excel
Set metadata 'author'
Parameters
string|null $author
setMetaCompany()
public function setMetaCompany(?string $company = ''): Excel
Set metadata 'company'
Parameters
string|null $company
setMetadata()
public function setMetadata($key, $value): Excel
Set metadata
Parameters
$key$value
setMetaDescription()
public function setMetaDescription(?string $description = ''): Excel
Set metadata 'description'
Parameters
string|null $description
setMetaKeywords()
public function setMetaKeywords($keywords): Excel
Set metadata 'keywords'
Parameters
mixed $keywords
setMetaSubject()
public function setMetaSubject(?string $subject = ''): Excel
Set metadata 'subject'
Parameters
string|null $subject
setMetaTitle()
public function setMetaTitle(?string $title = ''): Excel
Set metadata 'title'
Parameters
string|null $title
setR1C1()
public function setR1C1(bool $option = true): Excel
Set R1C1 notation mode
Parameters
bool $option
setRightToLeft()
public function setRightToLeft(bool $isRightToLeft)
Set right-to-left orientation
Parameters
bool $isRightToLeft
setSharedString()
public function setSharedString(bool $option = true): Excel
Set the usage of shared strings
Parameters
bool $option
setSubject()
public function setSubject(?string $subject = ''): Excel
Set the subject of the document
Parameters
string|null $subject
setTitle()
public function setTitle(?string $title = ''): Excel
Set the title of the document
Parameters
string|null $title
sheet()
public function sheet($index): ?Sheet
Returns sheet by number or nameReturn the first sheet if number or name omitted
Parameters
int|string|null $index– - number or name of sheet
unprotect()
public function unprotect(): Excel
Unprotect workbook
Parameters
None