Class \avadim\FastExcelLaravel\ExcelWriter

Source: 4.3.0 · 2d73434

On this page


__construct()


php
public function __construct(?array $options = [])

Excel constructor

Parameters

  • array|null $options -- Optional parameters: ['temp_dir' => ..., 'temp_prefix' => ..., 'auto_convert_number' => ..., 'shared_string' => ...]

cellAddress()


php
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

php
cellAddress(3, 3) => 'C3'
cellAddress(43, 27) => 'AA43'
cellAddress(43, 27, true) => '$AA$43'
cellAddress(43, 27, false, true) => 'AA$43'

colIndex()


php
public static function colIndex(string $colLetter): int

Convert letter to index (ZERO based)

Parameters

  • string $colLetter

colIndexRange()


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


php
public static function colLetter(int $colNumber): string

Convert column number to letter

Parameters

  • int $colNumber -- ONE based

colLetterRange()


php
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

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


php
public static function colNumber(string $colLetter): int

Convert letter to number (ONE based)

Parameters

  • string $colLetter

colNumberRange()


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


php
public static function create($sheets, ?array $options = []): ExcelWriter

Create XLSX for export

Parameters

  • string|array $sheets
  • array|null $options

createSheet()


php
public static function createSheet(string $sheetName): SheetWriter

Create SheetWriter instance

Parameters

  • string $sheetName

fullAddress()


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


php
public static function generateUuid(): string

Generate UUID v4

Parameters

None


newStyle()


php
public static function newStyle(): avadim\FastExcelWriter\Style\Style

Create a new instance of Style class

Parameters

None


pixelsToEMU()


php
public static function pixelsToEMU($pixels): float|int

Convert pixels to EMU (English Metric Units)

Parameters

  • int|float $pixels

rangeRelOffsets()


php
public static function rangeRelOffsets(string $relAddress): array

Return offsets by relative address (zero based)

Parameters

  • string $relAddress

setTempDir()


php
public static function setTempDir($tempDir)

Set dir for temporary files

Parameters

  • $tempDir

toTimestamp()


php
public static function toTimestamp($value): float|bool

Convert value (int or string) to Excel timestamp

Parameters

  • int|string $value

addDefinedName()


php
public function addDefinedName(string $name, string $range, 
                               ?array $attributes = []): avadim\FastExcelWriter\Excel

Add a defined name

Parameters

  • string $name
  • string $range
  • array|null $attributes

addNamedRange()


php
public function addNamedRange(string $range, 
                              string $name): avadim\FastExcelWriter\Excel

Add a named range

Parameters

  • string $range
  • string $name

addSharedString()


php
public function addSharedString(string $string, ?bool $richText = false): int

Add a string to the shared strings table

Parameters

  • string $string
  • bool|null $richText

download()


php
public function download(?string $name = null)

Download generated file to client (send to browser)

Parameters

  • string|null $name

exportModel()


php
public function exportModel($model, ?array $rowStyle = null, 
                            ?array $cellStyles = null): ExcelWriter

Export a model to the current sheet. Accepts a model class name or instance, an Eloquent builder, a query builder or a relation, see SheetWriter::exportModel()

Parameters

  • string|Model|EloquentBuilder|QueryBuilder|Relation $model
  • array|null $rowStyle
  • array|null $cellStyles

getDefaultFormatStyles()


php
public function getDefaultFormatStyles(): array

Get default format styles

Parameters

None


getDefaultSheetName()


php
public function getDefaultSheetName(): string

Get the default sheet name

Parameters

None


getDefaultStyle()


php
public function getDefaultStyle(): array

Get default style

Parameters

None


getDefinedNames()


php
public function getDefinedNames(): array

Get all defined names

Parameters

None


getFileName()


php
public function getFileName(): string

Returns default filename

Parameters

None


getImageFiles()


php
public function getImageFiles(): array

Get list of all loaded image files

Parameters

None


getMetadata()


php
public function getMetadata($key): mixed

Get metadata

Parameters

  • null $key

getSharedStrings()


php
public function getSharedStrings(): array

Get the shared strings table

Parameters

None


getSharedStringsRefCount()


php
public function getSharedStringsRefCount(): int

Total number of shared string references (the count attribute of <sst>)

Parameters

None


getSheet()


php
public function getSheet($index): ?avadim\FastExcelWriter\Sheet

Alias of sheet()

Parameters

  • int|string|null $index -- - number or name of sheet

getSheets()


php
public function getSheets(): array

Returns all sheets

Parameters

None


getWriter()


php
public function getWriter(): Writer

Get the writer instance

Parameters

None


isR1C1()


php
public function isR1C1(): bool

Is R1C1 notation mode enabled?

Parameters

None


isRightToLeft()


php
public function isRightToLeft(): bool

Get right-to-left orientation

Parameters

None


makeSheet()


php
public function makeSheet(?string $sheetName = null): avadim\FastExcelWriter\Sheet

Creates and returns a new sheet

Parameters

  • string|null $sheetName

output()


php
public function output(?string $name = null): void

Alias of download()

Parameters

  • string|null $name

protect()


php
public function protect(?string $password = null): avadim\FastExcelWriter\Excel

Protect workbook

Parameters

  • string|null $password

removeSheet()


php
public function removeSheet($index): avadim\FastExcelWriter\Excel

Removes sheet by index or name of sheet.Removes the first sheet of index omitted

Parameters

  • int|string|null $index

save()


php
public function save(?string $fileName = null, ?bool $overWrite = true): bool

Save generated XLSX-file

Parameters

  • string|null $fileName
  • bool|null $overWrite

saveTo()


php
public function saveTo(string $filePath, ?bool $overWrite = true): bool

Save file to the storage directory. The path is always resolved relative to storage_path() (not to a Storage disk root), missing directories are created. Use save() to save to an arbitrary path or store() to save to a disk

Parameters

  • string $filePath
  • bool|null $overWrite

setActiveSheet()


php
public function setActiveSheet(string $name): avadim\FastExcelWriter\Excel

Set active (default) sheet by case-insensitive name

Parameters

  • string $name

setAuthor()


php
public function setAuthor(?string $author = ''): avadim\FastExcelWriter\Excel

Set the author of the document

Parameters

  • string|null $author

setCompany()


php
public function setCompany(?string $company = ''): avadim\FastExcelWriter\Excel

Set the company of the document

Parameters

  • string|null $company

setDefaultDateFormat()


php
public function setDefaultDateFormat(string $format): avadim\FastExcelWriter\Excel

Set the default date format of the workbook (the '@date' style). It overrides the format of the locale.

Parameters

  • string $format -- e.g. 'DD.MM.YYYY'

setDefaultDateTimeFormat()


php
public function setDefaultDateTimeFormat(string $format): avadim\FastExcelWriter\Excel

Set the default date and time format of the workbook (the '@datetime' style, used for DateTime values).

Parameters

  • string $format -- e.g. 'DD.MM.YYYY HH:MM'

setDefaultFont()


php
public function setDefaultFont(array $fontOptions): avadim\FastExcelWriter\Excel

Set default font options

Parameters

  • array $fontOptions

setDefaultFontName()


php
public function setDefaultFontName(string $fontName): avadim\FastExcelWriter\Excel

Set default font name

Parameters

  • string $fontName

setDefaultFormat()


php
public function setDefaultFormat(string $formatName, string $format): avadim\FastExcelWriter\Excel

Set a format of the workbook which overrides the format of the locale.

Parameters

  • string $formatName -- format name, e.g. 'date', '@date', 'DATETIME'
  • string $format -- format pattern, e.g. 'DD.MM.YYYY'

setDefaultLocale()


php
public function setDefaultLocale()

Set default locale from the current environment

Parameters

None


setDefaultStyle()


php
public function setDefaultStyle(array $style): avadim\FastExcelWriter\Excel

Set default style

Parameters

  • array $style

setDefaultTimeFormat()


php
public function setDefaultTimeFormat(string $format): avadim\FastExcelWriter\Excel

Set the default time format of the workbook (the '@time' style).

Parameters

  • string $format -- e.g. 'HH:MM'

setDescription()


php
public function setDescription(?string $description = ''): avadim\FastExcelWriter\Excel

Set the description of the document

Parameters

  • string|null $description

setFileName()


php
public function setFileName(string $fileName): avadim\FastExcelWriter\Excel

Sets default filename for saving

Parameters

  • string $fileName

setKeywords()


php
public function setKeywords($keywords): avadim\FastExcelWriter\Excel

Set the keywords of the document

Parameters

  • string|array $keywords

setLocale()


php
public function setLocale(string $locale, 
                          ?string $dir = null): avadim\FastExcelWriter\Excel

Set locale information

Parameters

  • string $locale
  • string|null $dir

setMetaAuthor()


php
public function setMetaAuthor(?string $author = ''): avadim\FastExcelWriter\Excel

Set metadata 'author'

Parameters

  • string|null $author

setMetaCompany()


php
public function setMetaCompany(?string $company = ''): avadim\FastExcelWriter\Excel

Set metadata 'company'

Parameters

  • string|null $company

setMetadata()


php
public function setMetadata($key, $value): avadim\FastExcelWriter\Excel

Set metadata

Parameters

  • $key
  • $value

setMetaDescription()


php
public function setMetaDescription(?string $description = ''): avadim\FastExcelWriter\Excel

Set metadata 'description'

Parameters

  • string|null $description

setMetaKeywords()


php
public function setMetaKeywords($keywords): avadim\FastExcelWriter\Excel

Set metadata 'keywords'

Parameters

  • mixed $keywords

setMetaSubject()


php
public function setMetaSubject(?string $subject = ''): avadim\FastExcelWriter\Excel

Set metadata 'subject'

Parameters

  • string|null $subject

setMetaTitle()


php
public function setMetaTitle(?string $title = ''): avadim\FastExcelWriter\Excel

Set metadata 'title'

Parameters

  • string|null $title

setR1C1()


php
public function setR1C1(bool $option = true): avadim\FastExcelWriter\Excel

Set R1C1 notation mode

Parameters

  • bool $option

setRightToLeft()


php
public function setRightToLeft(bool $isRightToLeft)

Set right-to-left orientation

Parameters

  • bool $isRightToLeft

setSharedString()


php
public function setSharedString(bool $option = true): avadim\FastExcelWriter\Excel

Set the usage of shared strings

Parameters

  • bool $option

setSubject()


php
public function setSubject(?string $subject = ''): avadim\FastExcelWriter\Excel

Set the subject of the document

Parameters

  • string|null $subject

setTitle()


php
public function setTitle(?string $title = ''): avadim\FastExcelWriter\Excel

Set the title of the document

Parameters

  • string|null $title

sheet()


php
public function sheet($index): SheetWriter

Returns sheet by number or name of sheet.Return the first sheet if number or name omitted

Parameters

  • int|string|null $index -- - number or name of sheet

store()


php
public function store($disk, $path): bool

Store file to specified disk

Parameters

  • $disk
  • $path

unprotect()


php
public function unprotect(): avadim\FastExcelWriter\Excel

Unprotect workbook

Parameters

None


writeData()


php
public function writeData($data): ExcelWriter

Write data to the current sheet. Accepts any iterable (array, Collection, LazyCollection, Model::cursor(), a generator, ...) or a callable that returns an iterable

Parameters

  • iterable|callable $data

FastExcelLaravel 4.3.0 · Search this library and version.

Loading search…

Could not load search. Please try again.

No results. Try another word or method name.