Skip to content

Class \avadim\FastExcelWriter\Excel



__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 based
  • int $colNumber – ONE based
  • bool|null $absolute
  • bool|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 $colKeys
  • int|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 names
  • array|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 $sheetName
  • string $address
  • bool|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 $name
  • string $range
  • array|null $attributes

addNamedRange()


public function addNamedRange(string $range, string $name): Excel
Add a named range

Parameters

  • string $range
  • string $name

addSharedString()


public function addSharedString(string $string, ?bool $richText = false): int
Add a string to the shared strings table

Parameters

  • string $string
  • bool|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 $fileName
  • bool|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 $locale
  • string|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