Class \avadim\FastExcelLaravel\SheetWriter

Source: 4.3.0 · 2d73434

On this page


__construct()


php
public function __construct(string $sheetName)

Sheet constructor

Parameters

  • string $sheetName

addCellStyle()


php
public function addCellStyle(string $cellAddr, 
                             $style): avadim\FastExcelWriter\Sheet

Add additional styles to a cell

Parameters

  • string $cellAddr
  • array|Style $style

addChart()


php
public function addChart(string $range, 
                         avadim\FastExcelWriter\Charts\Chart $chart): avadim\FastExcelWriter\Sheet

Add a chart object to the specified range of cells

Parameters

  • string $range -- Set the position where the chart should appear in the worksheet
  • Chart $chart -- Chart object

addConditionalFormatting()


php
public function addConditionalFormatting(string $range, 
                                         $conditionals): avadim\FastExcelWriter\Sheet

Add a conditional formatting object to the specified range of cells

Parameters

  • string $range
  • Conditional|Conditional[] $conditionals

addDataValidation()


php
public function addDataValidation(string $range, 
                                  avadim\FastExcelWriter\DataValidation\DataValidation $validation): avadim\FastExcelWriter\Sheet

Add a data validation object to the specified range of cells

Parameters

  • string $range
  • DataValidation $validation

addImage()


php
public function addImage(string $cell, string $imageFile, 
                         ?array $imageStyle = []): avadim\FastExcelWriter\Sheet

Add an image to the sheet from a local file, URL or image string in base64

Parameters

  • string $cell -- Cell address
  • string $imageFile -- URL, local path or image string in base64
  • array|null $imageStyle -- ['width' => ..., 'height' => ..., 'hyperlink' => ...]

Examples

php
$sheet->addImage('A1', 'path/to/file');
$sheet->addImage('A1', 'path/to/file', ['width' => 100]);

addNamedRange()


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

Define named range

Parameters

  • string $range
  • string $name

Examples

php
$sheet->addNamedRange('B3:C5', 'Demo');

addNote()


php
public function addNote($cell, $comment, 
                        array $noteStyle = []): avadim\FastExcelWriter\Sheet

Add a note to the sheet

Parameters

  • string|mixed $cell
  • string|array|null $comment
  • array $noteStyle

Examples

php
$sheet->addNote('A1', $noteText, $noteStyle);
$sheet->writeCell($cellValue)->addNote($noteText, $noteStyle);

addStyle()


php
public function addStyle(string $cellAddr, 
                         $style): avadim\FastExcelWriter\Sheet

Alias for 'addCellStyle()'

Parameters

  • string $cellAddr
  • array|Style $style

allowAutoFilter()


php
public function allowAutoFilter(?bool $allow = true): avadim\FastExcelWriter\Sheet

AutoFilters should be allowed to operate when the sheet is protected

Parameters

  • bool|null $allow

allowDeleteColumns()


php
public function allowDeleteColumns(?bool $allow = true): avadim\FastExcelWriter\Sheet

Deleting columns should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowDeleteRows()


php
public function allowDeleteRows(?bool $allow = true): avadim\FastExcelWriter\Sheet

Deleting rows should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowEditObjects()


php
public function allowEditObjects(?bool $allow = true): avadim\FastExcelWriter\Sheet

Objects are allowed to be edited when the sheet is protected

Parameters

  • bool|null $allow

allowEditScenarios()


php
public function allowEditScenarios(?bool $allow = true): avadim\FastExcelWriter\Sheet

Scenarios are allowed to be edited when the sheet is protected

Parameters

  • bool|null $allow

allowFormatCells()


php
public function allowFormatCells(?bool $allow = true): avadim\FastExcelWriter\Sheet

Formatting cells should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowFormatColumns()


php
public function allowFormatColumns(?bool $allow = true): avadim\FastExcelWriter\Sheet

Formatting columns should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowFormatRows()


php
public function allowFormatRows(?bool $allow = true): avadim\FastExcelWriter\Sheet

Formatting rows should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowInsertColumns()


php
public function allowInsertColumns(?bool $allow = true): avadim\FastExcelWriter\Sheet

Inserting columns should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowInsertHyperlinks()


php
public function allowInsertHyperlinks(?bool $allow = true): avadim\FastExcelWriter\Sheet

Inserting hyperlinks should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowInsertRows()


php
public function allowInsertRows(?bool $allow = true): avadim\FastExcelWriter\Sheet

Inserting rows should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowPivotTables()


php
public function allowPivotTables(?bool $allow = true): avadim\FastExcelWriter\Sheet

PivotTables should be allowed to operate when the sheet is protected

Parameters

  • bool|null $allow

allowSelectCells()


php
public function allowSelectCells(?bool $allow = true): avadim\FastExcelWriter\Sheet

Selection of any cells should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowSelectLockedCells()


php
public function allowSelectLockedCells(?bool $allow = true): avadim\FastExcelWriter\Sheet

Selection of locked cells should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowSelectUnlockedCells()


php
public function allowSelectUnlockedCells(?bool $allow = true): avadim\FastExcelWriter\Sheet

Selection of unlocked cells should be allowed when the sheet is protected

Parameters

  • bool|null $allow

allowSort()


php
public function allowSort(?bool $allow = true): avadim\FastExcelWriter\Sheet

Sorting should be allowed when the sheet is protected

Parameters

  • bool|null $allow

applyAlignLeft()


php
public function applyAlignLeft(): avadim\FastExcelWriter\Sheet

Apply left alignment to content

Parameters

None


applyAlignRight()


php
public function applyAlignRight(): avadim\FastExcelWriter\Sheet

Apply right alignment to content

Parameters

None


applyBgColor()


php
public function applyBgColor(string $color, 
                             ?string $pattern = null): avadim\FastExcelWriter\Sheet

Alias of 'applyFillColor()'

Parameters

  • string $color
  • string|null $pattern

applyBorder()


php
public function applyBorder(string $style, 
                            ?string $color = '#000000'): avadim\FastExcelWriter\Sheet

Sets all borders style

Parameters

  • string $style
  • string|null $color

applyBorderBottom()


php
public function applyBorderBottom(string $style, 
                                  ?string $color = '#000000'): avadim\FastExcelWriter\Sheet

Apply bottom border style and color to the selected area

Parameters

  • string $style
  • string|null $color

applyBorderLeft()


php
public function applyBorderLeft(string $style, 
                                ?string $color = '#000000'): avadim\FastExcelWriter\Sheet

Apply left border style and color to the selected area

Parameters

  • string $style
  • string|null $color

applyBorderRight()


php
public function applyBorderRight(string $style, 
                                 ?string $color = '#000000'): avadim\FastExcelWriter\Sheet

Apply right border style and color to the selected area

Parameters

  • string $style
  • string|null $color

applyBorderTop()


php
public function applyBorderTop(string $style, 
                               ?string $color = '#000000'): avadim\FastExcelWriter\Sheet

Apply top border style and color to the selected area

Parameters

  • string $style
  • string|null $color

applyColor()


php
public function applyColor(string $color): avadim\FastExcelWriter\Sheet

Alias of 'setFontColor()'

Parameters

  • string $color

applyConditionalFormatting()


php
public function applyConditionalFormatting($conditionals): avadim\FastExcelWriter\Sheet

Apply conditional formatting to the selected area

Parameters

  • Conditional|Conditional[] $conditionals

applyDataValidation()


php
public function applyDataValidation(avadim\FastExcelWriter\DataValidation\DataValidation $validation): avadim\FastExcelWriter\Sheet

Apply data validation to the selected area

Parameters

  • DataValidation $validation

applyFillColor()


php
public function applyFillColor(string $color, 
                               ?string $pattern = null): avadim\FastExcelWriter\Sheet

Fill background color

Parameters

  • string $color
  • string|null $pattern

applyFillGradient()


php
public function applyFillGradient(string $color1, string $color2, 
                                  ?int $degree = null): avadim\FastExcelWriter\Sheet

Fill background by gradient

Parameters

  • string $color1
  • string $color2
  • int|null $degree

applyFont()


php
public function applyFont(string $fontName, ?int $fontSize = null, 
                          ?string $fontStyle = null, 
                          ?string $fontColor = null): avadim\FastExcelWriter\Sheet

Apply font settings to the selected area

Parameters

  • string $fontName
  • int|null $fontSize
  • string|null $fontStyle
  • string|null $fontColor

applyFontColor()


php
public function applyFontColor(string $fontColor): avadim\FastExcelWriter\Sheet

Apply font color to the selected area

Parameters

  • string $fontColor

applyFontName()


php
public function applyFontName(string $fontName): avadim\FastExcelWriter\Sheet

Apply font name to the selected area

Parameters

  • string $fontName

applyFontSize()


php
public function applyFontSize(float $fontSize): avadim\FastExcelWriter\Sheet

Apply font size to the selected area

Parameters

  • float $fontSize

applyFontStyle()


php
public function applyFontStyle(string $fontStyle): avadim\FastExcelWriter\Sheet

Apply font style (bold, italic, etc.) to the selected area

Parameters

  • string $fontStyle

applyFontStyleBold()


php
public function applyFontStyleBold(): avadim\FastExcelWriter\Sheet

Apply bold font style to the selected area

Parameters

None


applyFontStyleItalic()


php
public function applyFontStyleItalic(): avadim\FastExcelWriter\Sheet

Apply italic font style to the selected area

Parameters

None


applyFontStyleStrikethrough()


php
public function applyFontStyleStrikethrough(): avadim\FastExcelWriter\Sheet

Apply strikethrough font style to the selected area

Parameters

None


applyFontStyleUnderline()


php
public function applyFontStyleUnderline(?bool $double = false): avadim\FastExcelWriter\Sheet

Apply underline font style to the selected area

Parameters

  • bool|null $double

applyFormat()


php
public function applyFormat($format): avadim\FastExcelWriter\Sheet

Set value format for the selected area

Parameters

  • string|array $format

applyHide()


php
public function applyHide(?bool $hide = true): avadim\FastExcelWriter\Sheet

Set hidden protection for the selected area

Parameters

  • bool|null $hide

applyIndentDistributed()


php
public function applyIndentDistributed(int $indent): avadim\FastExcelWriter\Sheet

Set distributed indent for the selected area

Parameters

  • int $indent

applyIndentLeft()


php
public function applyIndentLeft(int $indent): avadim\FastExcelWriter\Sheet

Set left indent for the selected area

Parameters

  • int $indent

applyIndentRight()


php
public function applyIndentRight(int $indent): avadim\FastExcelWriter\Sheet

Set right indent for the selected area

Parameters

  • int $indent

applyInnerBorder()


php
public function applyInnerBorder(string $style, 
                                 ?string $color = '#000000'): avadim\FastExcelWriter\Sheet

Apply inner border style and color to the selected area

Parameters

  • string $style
  • string|null $color

applyNamedRange()


php
public function applyNamedRange(string $name): avadim\FastExcelWriter\Sheet

Apply named range to the selected area

Parameters

  • string $name

applyOuterBorder()


php
public function applyOuterBorder(string $style, 
                                 ?string $color = '#000000'): avadim\FastExcelWriter\Sheet

Apply outer border style and color to the selected area

Parameters

  • string $style
  • string|null $color

applyRowHeight()


php
public function applyRowHeight(float $height): avadim\FastExcelWriter\Sheet

Sets height to the current row

Parameters

  • float $height

applyRowOutlineLevel()


php
public function applyRowOutlineLevel(int $outlineLevel): avadim\FastExcelWriter\Sheet

Set outline level for the current row

Parameters

  • int $outlineLevel

applyStyle()


php
public function applyStyle($style): avadim\FastExcelWriter\Sheet

Apply the style

Parameters

  • array|Style $style

applyTextAlign()


php
public function applyTextAlign(string $textAlign, 
                               ?string $verticalAlign = null): avadim\FastExcelWriter\Sheet

Apply horizontal alignment to the selected area

Parameters

  • string $textAlign
  • string|null $verticalAlign

applyTextCenter()


php
public function applyTextCenter(): avadim\FastExcelWriter\Sheet

Apply horizontal and vertical center alignment to the selected area

Parameters

None


applyTextColor()


php
public function applyTextColor(string $color): avadim\FastExcelWriter\Sheet

Set text color for the selected area

Parameters

  • string $color

applyTextRotation()


php
public function applyTextRotation(int $degrees): avadim\FastExcelWriter\Sheet

Set text rotation for the selected area

Parameters

  • int $degrees

applyTextWrap()


php
public function applyTextWrap(?bool $textWrap = true): avadim\FastExcelWriter\Sheet

Set text wrap for the selected area

Parameters

  • bool|null $textWrap

applyUnlock()


php
public function applyUnlock(?bool $unlock = true): avadim\FastExcelWriter\Sheet

Set unlock protection for the selected area

Parameters

  • bool $unlock

applyVerticalAlign()


php
public function applyVerticalAlign(string $verticalAlign): avadim\FastExcelWriter\Sheet

Apply vertical alignment to the selected area

Parameters

  • string $verticalAlign

beginArea()


php
public function beginArea(?string $cellAddress = null): avadim\FastExcelWriter\Area

Begin a new area

Parameters

  • string|null $cellAddress -- Upper left cell of area

beginOutlineLevel()


php
public function beginOutlineLevel(?bool $collapsed = false): avadim\FastExcelWriter\Sheet

Start a new outline level for rows

Parameters

  • bool|null $collapsed

cell()


php
public function cell($cellAddress): avadim\FastExcelWriter\Sheet

Select a single cell or cell range in the current row

Parameters

  • string|array $cellAddress

Examples

php
$sheet->cell('B5')->writeCell($value);
$sheet->cell('B5:C7')->applyBorder('thin');
$sheet->cell(['col' => 2, 'row' => 5])->applyUnlock();
$sheet->cell([2, 5])->applyColor($color);

clearAreas()


php
public function clearAreas(): avadim\FastExcelWriter\Sheet

Clear all defined areas

Parameters

None


endAreas()


php
public function endAreas(): avadim\FastExcelWriter\Sheet

Parameters

None


endOutlineLevel()


php
public function endOutlineLevel(): avadim\FastExcelWriter\Sheet

End the current outline level for rows

Parameters

None


exportModel()


php
public function exportModel($model, $rowStyle, 
                            ?array $colStyles = null): SheetWriter

Export a model to the sheet. Accepts a model class name or instance (all records are exported), an Eloquent builder, a query builder or a relation (only the matching records are exported). Records are read lazily through cursor()

Parameters

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

formatAttributes()


php
public function formatAttributes(array $formats): SheetWriter

Set format attributes

Parameters

  • array $formats

getCharts()


php
public function getCharts(): array

Get all charts in the sheet

Parameters

None


getColAttributes()


php
public function getColAttributes(): array

Get columns attributes

Parameters

None


getConditionalFormatting()


php
public function getConditionalFormatting(): array

Get all conditional formatting in the sheet

Parameters

None


getCurrentCell()


php
public function getCurrentCell(): string

Returns address of the current cell

Parameters

None


getCurrentCol()


php
public function getCurrentCol(): string

Returns current column letter

Parameters

None


getCurrentColId()


php
public function getCurrentColId(): int

Get current column index (0-based)

Parameters

None


getCurrentRow()


php
public function getCurrentRow(): int

Returns current row number

Parameters

None


getCurrentRowId()


php
public function getCurrentRowId(): int

Get current row index (0-based)

Parameters

None


getDataValidations()


php
public function getDataValidations(): array

Get all data validations in the sheet

Parameters

None


getDefaultStyle()


php
public function getDefaultStyle(): array

Returns default style

Parameters

None


getHeaderFooterOptions()


php
public function getHeaderFooterOptions(): array

Get header and footer options

Parameters

None


getHyperlinks()


php
public function getHyperlinks(): array

Returns added hyperlinks

Parameters

None


getImages()


php
public function getImages(): array

Get all images in the sheet

Parameters

None


getLastCell()


php
public function getLastCell(?bool $absolute = false): string

Get address of the last touched cell

Parameters

  • bool|null $absolute

getLastRange()


php
public function getLastRange(?bool $absolute = false): string

Get address of the last touched range

Parameters

  • bool|null $absolute

getMergedCells()


php
public function getMergedCells(): array

Returns merged cells

Parameters

None


getName()


php
public function getName(): string

Get sheet name

Parameters

None


getNamedRanges()


php
public function getNamedRanges(): array

Returns named ranges with full addresses

Parameters

None


getNotes()


php
public function getNotes(): array

Get all notes in the sheet

Parameters

None


getOutlineLevel()


php
public function getOutlineLevel(): int

Get the current outline level for rows

Parameters

None


isName()


php
public function isName(string $name): bool

Case-insensitive name checking

Parameters

  • string $name

isRightToLeft()


php
public function isRightToLeft(): bool

Check if the sheet is right-to-left

Parameters

None


makeArea()


php
public function makeArea(string $range): avadim\FastExcelWriter\Area

Make area for writing

Parameters

  • string $range -- A1:Z9 or R1C1:R9C28

mapping()


php
public function mapping($callback): SheetWriter

Set mapping callback for the sheet

Parameters

  • $callback

mergeCells()


php
public function mergeCells($rangeSet, 
                           ?int $mergeFlag = 0): avadim\FastExcelWriter\Sheet

Merge cells

Parameters

  • array|string|int $rangeSet
  • int|null $mergeFlag -- Action in case of intersection: 0 - exception; 1 - replace; 2 - keep; -1 - skip intersection check

Examples

php
$sheet->mergeCells('A1:C3');
$sheet->mergeCells(['A1:B2', 'C1:D2']);
$sheet->mergeCells('B5:C7', $value, Sheet:MERGE_NO_CHECK); // don't check for intersection of merged cells

mergeRelCells()


php
public function mergeRelCells($rangeSet): avadim\FastExcelWriter\Sheet

Merge relative cells

Parameters

  • array|string|int $rangeSet

Examples

php
$sheet->mergeCells('C3:E8');
$sheet->mergeCells(3); // 3 columns of current row, equivalent of mergeCells('A5:C5') if current row is 5
$sheet->mergeCells(['RC3:RC5', 'RC6:RC7']); // equivalent of mergeCells(['C7:E7', 'F7:G7']) if current row is 7

nextCell()


php
public function nextCell(): avadim\FastExcelWriter\Sheet

Move pointer to the next cell

Parameters

None


nextRow()


php
public function nextRow($style, 
                        ?bool $forceRow = false): avadim\FastExcelWriter\Sheet

Move to the next row

Parameters

  • array|Style|null $style
  • bool|null $forceRow

pageFitToHeight()


php
public function pageFitToHeight($numPage): avadim\FastExcelWriter\Sheet

Set page to fit to height

Parameters

  • int|string|null $numPage

pageFitToWidth()


php
public function pageFitToWidth($numPage): avadim\FastExcelWriter\Sheet

Set page to fit to width

Parameters

  • int|string|null $numPage

pageFooter()


php
public function pageFooter($footer): avadim\FastExcelWriter\Sheet

Set the footer for all pages

Parameters

  • string|array $footer

pageFooterEven()


php
public function pageFooterEven($footer): avadim\FastExcelWriter\Sheet

Set footer for even pages

Parameters

  • string|array $footer

pageFooterFirst()


php
public function pageFooterFirst($footer): avadim\FastExcelWriter\Sheet

Set the footer for the first page

Parameters

  • string|array $footer

pageFooterOdd()


php
public function pageFooterOdd(string $footer): avadim\FastExcelWriter\Sheet

Set footer for odd pages

Parameters

  • string $footer

pageHeader()


php
public function pageHeader($header): avadim\FastExcelWriter\Sheet

Set page header for all pages

Parameters

  • string|array $header

pageHeaderEven()


php
public function pageHeaderEven($header): avadim\FastExcelWriter\Sheet

Set header for even pages

Parameters

  • string|array $header

pageHeaderFirst()


php
public function pageHeaderFirst($header): avadim\FastExcelWriter\Sheet

Set the header for the first page

Parameters

  • string|array $header

pageHeaderFooter()


php
public function pageHeaderFooter(?string $header, 
                                 ?string $footer): avadim\FastExcelWriter\Sheet

Set the center header and footer for all pages

Parameters

  • string|null $header
  • string|null $footer

pageHeaderOdd()


php
public function pageHeaderOdd($header): avadim\FastExcelWriter\Sheet

Set header for odd pages

Parameters

  • string|array $header

pageLandscape()


php
public function pageLandscape(): avadim\FastExcelWriter\Sheet

Set page orientation as Landscape

Parameters

None


pageMarginBottom()


php
public function pageMarginBottom($value): avadim\FastExcelWriter\Sheet

Bottom Page Margin in mm|cm|in

Parameters

  • string|float $value

pageMarginFooter()


php
public function pageMarginFooter($value): avadim\FastExcelWriter\Sheet

Footer Page Margin in mm|cm|in

Parameters

  • string|float $value

pageMarginHeader()


php
public function pageMarginHeader($value): avadim\FastExcelWriter\Sheet

Header Page Margin in mm|cm|in

Parameters

  • string|float $value

pageMarginLeft()


php
public function pageMarginLeft($value): avadim\FastExcelWriter\Sheet

Left Page Margin in mm|cm|in

Parameters

  • string|float $value

pageMarginRight()


php
public function pageMarginRight($value): avadim\FastExcelWriter\Sheet

Right page margin in mm|cm|in

Parameters

  • string|float $value

pageMargins()


php
public function pageMargins(array $margins): avadim\FastExcelWriter\Sheet

Page margins for a sheet or a custom sheet view in mm|cm|in

Parameters

  • array $margins

pageMarginTop()


php
public function pageMarginTop($value): avadim\FastExcelWriter\Sheet

Top Page Margin in mm|cm|in

Parameters

  • string|float $value

pageOrientationLandscape()


php
public function pageOrientationLandscape(): avadim\FastExcelWriter\Sheet

Set page orientation as Landscape, alias of pageLandscape()

Parameters

None


pageOrientationPortrait()


php
public function pageOrientationPortrait(): avadim\FastExcelWriter\Sheet

Set page orientation as Portrait, alias of pagePortrait()

Parameters

None


pagePaperHeight()


php
public function pagePaperHeight($paperHeight): avadim\FastExcelWriter\Sheet

Height of custom paper as a number followed by a unit identifier mm|cm|in (ex: 297mm, 11in)

Parameters

  • string|float|int $paperHeight

pagePaperSize()


php
public function pagePaperSize(int $paperSize): avadim\FastExcelWriter\Sheet

Set Paper size (when paperHeight and paperWidth are specified, paperSize should be ignored)

Parameters

  • int $paperSize

pagePaperSizeA3()


php
public function pagePaperSizeA3(): avadim\FastExcelWriter\Sheet

Set Paper Size to A3 (when paperHeight and paperWidth are specified, paperSize should be ignored)

Parameters

None


pagePaperSizeA4()


php
public function pagePaperSizeA4(): avadim\FastExcelWriter\Sheet

Set Paper Size to A4 (when paperHeight and paperWidth are specified, paperSize should be ignored)

Parameters

None


pagePaperSizeLegal()


php
public function pagePaperSizeLegal(): avadim\FastExcelWriter\Sheet

Set Paper Size to Legal (when paperHeight and paperWidth are specified, paperSize should be ignored)

Parameters

None


pagePaperSizeLetter()


php
public function pagePaperSizeLetter(): avadim\FastExcelWriter\Sheet

Set Paper Size to Letter (when paperHeight and paperWidth are specified, paperSize should be ignored)

Parameters

None


pagePaperWidth()


php
public function pagePaperWidth($paperWidth): avadim\FastExcelWriter\Sheet

Width of custom paper as a number followed by a unit identifier mm|cm|in (ex: 21cm, 8.5in)

Parameters

  • string|float|int $paperWidth

pagePortrait()


php
public function pagePortrait(): avadim\FastExcelWriter\Sheet

Set page orientation as Portrait

Parameters

None


pageScale()


php
public function pageScale(int $scale): avadim\FastExcelWriter\Sheet

Set page scale

Parameters

  • int $scale

protect()


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

Protect sheet

Parameters

  • string|null $password

setActiveCell()


php
public function setActiveCell($cellAddress): avadim\FastExcelWriter\Sheet

Set active cell

Parameters

  • $cellAddress

setAutoFilter()


php
public function setAutoFilter($rowOrCell, 
                              ?int $col = 1): avadim\FastExcelWriter\Sheet

Set auto filter

Parameters

  • mixed|null $rowOrCell
  • int|null $col

Examples

php
$sheet->setAutoFilter(2);
$sheet->setAutoFilter('B2');
$sheet->setAutoFilter('B2:C4');

setBgColor()


php
public function setBgColor(string $cellAddr, 
                           string $color): avadim\FastExcelWriter\Sheet

Set background color for the specific cell or range

Parameters

  • string $cellAddr
  • string $color

setBottomNodesOptions()


php
public function setBottomNodesOptions(string $node, 
                                      array $options): avadim\FastExcelWriter\Sheet

Set multiple options for a bottom node

Parameters

  • string $node
  • array $options

setCellStyle()


php
public function setCellStyle(string $cellAddress, $style, 
                             ?bool $mergeStyles = false): avadim\FastExcelWriter\Sheet

Set style for the specific cell

Parameters

  • string $cellAddress -- Cell address
  • array|Style $style -- Style array or object
  • bool|null $mergeStyles -- True - merge style with previous style for this cell (if exists)

setColAutoWidth()


php
public function setColAutoWidth($col): avadim\FastExcelWriter\Sheet

Alias of setColWidthAuto($col)

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)

setColDataStyle()


php
public function setColDataStyle($colRange, 
                                $colStyle): avadim\FastExcelWriter\Sheet

Set styles of column cells (colors, formats, etc.)Styles are applied only to non-empty cells in a column and only take effect starting with the current row

Parameters

  • int|string|array $colRange
  • array|Style $colStyle

Examples

php
$sheet->setColDataStyle('B', ['width' = 20]); // style for cells of column 'B'
$sheet->setColDataStyle(2, ['width' = 20]); // 'B' is number 2 column
$sheet->setColDataStyle('B:D', ['width' = 'auto']); // options for range of columns
$sheet->setColDataStyle(['A', 'B', 'C'], $style); // options for several columns 'A', 'B' and 'C'

setColDataStyleArray()


php
public function setColDataStyleArray(array $colStyles): avadim\FastExcelWriter\Sheet

Set style of column cells (colors, formats, etc.)Styles are applied only to non-empty cells in a column and only take effect starting with the current row

Parameters

  • array $colStyles

Examples

php
$sheet->setColDataStyleArray(['B' => $style1, 'C' => $style2]); // options for columns 'B' and 'C'

setColFormat()


php
public function setColFormat($col, $format): avadim\FastExcelWriter\Sheet

Set a format of single or multiple column(s)

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)
  • mixed $format

setColFormats()


php
public function setColFormats(array $formats): avadim\FastExcelWriter\Sheet

Set formats of columns

Parameters

  • array $formats

setColFormula()


php
public function setColFormula($col, 
                              string $formula): avadim\FastExcelWriter\Sheet

Set formula for single or multiple column(s)

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)
  • string $formula

setColHidden()


php
public function setColHidden($col): avadim\FastExcelWriter\Sheet

Set a column as hidden

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)

setColMinWidth()


php
public function setColMinWidth($col, $width): avadim\FastExcelWriter\Sheet

Setting a minimal column's width

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)
  • int|float|string $width

setColMinWidths()


php
public function setColMinWidths(array $widths): avadim\FastExcelWriter\Sheet

Setting a multiple column's minimal width

Parameters

  • array $widths

Examples

php
$sheet->setColWidths(['B' => 10, 'C' => 'auto', 'E' => 30, 'F' => 40]);

setColOutlineLevel()


php
public function setColOutlineLevel($col, 
                                   int $outlineLevel): avadim\FastExcelWriter\Sheet

Set a column outline level

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)
  • int $outlineLevel

setColStyle()


php
public function setColStyle($colRange, $style): avadim\FastExcelWriter\Sheet

Set style of single or multiple column(s)Styles are applied to the entire sheet column(s) (even if it is empty)

Parameters

  • int|string|array $colRange -- Column number or column letter or column range (or array of these)
  • array|Style $style

Examples

php
$sheet->setColStyle('B', $style);
$sheet->setColStyle(2, $style); // 'B' is number 2 column
$sheet->setColStyle('C:F', $style);
$sheet->setColStyle(['A', 'B', 'C'], $style);

setColStyleArray()


php
public function setColStyleArray($colStyles): avadim\FastExcelWriter\Sheet

Set styles of single or multiple column(s)Styles are applied to the entire sheet column(s) (even if it is empty)

Parameters

  • array|Style $colStyles

Examples

php
$style1 = ['width' = 20];
$style2 = (new Style())->setColor('red');
$sheet->setColStyleArray(['B' => $style1, 'C' => $style2]);

setColVisible()


php
public function setColVisible($col, bool $val): avadim\FastExcelWriter\Sheet

Show/hide a column

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)
  • bool $val

setColWidth()


php
public function setColWidth($col, $width, 
                            ?bool $min = false): avadim\FastExcelWriter\Sheet

Set a width of single or multiple column(s)

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)
  • int|float|string $width
  • bool|null $min

setColWidthAuto()


php
public function setColWidthAuto($col): avadim\FastExcelWriter\Sheet

Set auto width of single or multiple column(s)

Parameters

  • int|string|array $col -- Column number or column letter (or array of these)

Examples

php
$sheet->setColWidthAuto(2);
$sheet->setColWidthAuto('B');
$sheet->setColWidthAuto(['B', 'C']);
$sheet->setColWidthAuto(['B:D']);

setColWidths()


php
public function setColWidths(array $widths, 
                             ?bool $min = false): avadim\FastExcelWriter\Sheet

Setting a multiple column's width

Parameters

  • array $widths
  • bool|null $min

Examples

php
$sheet->setColWidths(['B' => 10, 'C' => 'auto', 'E' => 30, 'F' => 40]);

setDefaultFont()


php
public function setDefaultFont($font): avadim\FastExcelWriter\Sheet

Set default font settings for the sheet

Parameters

  • string|array $font

setDefaultFontColor()


php
public function setDefaultFontColor(string $fontColor): avadim\FastExcelWriter\Sheet

Set default font color

Parameters

  • string $fontColor

setDefaultFontName()


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

Set default font name for the sheet

Parameters

  • string $fontName

setDefaultFontSize()


php
public function setDefaultFontSize(int $fontSize): avadim\FastExcelWriter\Sheet

Set default font size for the sheet

Parameters

  • int $fontSize

setDefaultFontStyle()


php
public function setDefaultFontStyle(string $fontStyle): avadim\FastExcelWriter\Sheet

Set default font style (bold, italic, etc.) for the sheet

Parameters

  • string $fontStyle

setDefaultFontStyleBold()


php
public function setDefaultFontStyleBold(): avadim\FastExcelWriter\Sheet

Set default font style as bold for the sheet

Parameters

None


setDefaultFontStyleItalic()


php
public function setDefaultFontStyleItalic(): avadim\FastExcelWriter\Sheet

Set default font style as italic

Parameters

None


setDefaultFontStyleStrikethrough()


php
public function setDefaultFontStyleStrikethrough(): avadim\FastExcelWriter\Sheet

Set default font style as strikethrough

Parameters

None


setDefaultFontStyleUnderline()


php
public function setDefaultFontStyleUnderline(?bool $double = false): avadim\FastExcelWriter\Sheet

Set default font style as underline

Parameters

  • bool|null $double

setDefaultStyle()


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

Sets default style

Parameters

  • array|Style $style

setFormat()


php
public function setFormat(string $cellAddr, 
                          string $format): avadim\FastExcelWriter\Sheet

Set value format for the specific cell or range

Parameters

  • string $cellAddr
  • string $format

setFormula()


php
public function setFormula($cellAddress, $value, 
                           $style): avadim\FastExcelWriter\Sheet

Set a formula to the single cell or to the cell range

Parameters

  • string|array $cellAddress
  • mixed $value
  • array|Style|null $style

Examples

php
$sheet->setFormula('B5', '=F23');
$sheet->setFormula('B5:C7', $formula, $style);
$sheet->setFormula(['col' => 2, 'row' => 5], '=R2C3+R3C4');
$sheet->setFormula([2, 5], '=SUM(A4:A18)');

setFreeze()


php
public function setFreeze($freezeRows, 
                          $freezeColumns): avadim\FastExcelWriter\Sheet

Freeze rows/columns

Parameters

  • mixed $freezeRows
  • mixed $freezeColumns

Examples

php
$sheet->setFreeze(3, 3); // number rows and columns to freeze
$sheet->setFreeze('C3'); // left top cell of the free area

setFreezeColumns()


php
public function setFreezeColumns(int $freezeColumns): avadim\FastExcelWriter\Sheet

Freeze columns

Parameters

  • int $freezeColumns -- Number columns to freeze

setFreezeRows()


php
public function setFreezeRows(int $freezeRows): avadim\FastExcelWriter\Sheet

Freeze rows

Parameters

  • int $freezeRows -- Number rows to freeze

setName()


php
public function setName(string $sheetName): avadim\FastExcelWriter\Sheet

Set sheet name

Parameters

  • string $sheetName

setOuterBorder()


php
public function setOuterBorder(string $range, 
                               $style): avadim\FastExcelWriter\Sheet

Set outer border for the specific range

Parameters

  • string $range
  • string|array|Style $style

setPrintArea()


php
public function setPrintArea(string $range): avadim\FastExcelWriter\Sheet

Set print area for the sheet

Parameters

  • string $range

setPrintCentered()


php
public function setPrintCentered(?bool $value = true): avadim\FastExcelWriter\Sheet

Center the print area horizontally and vertically

Parameters

  • bool|null $value

setPrintGridlines()


php
public function setPrintGridlines(?bool $bool = true): avadim\FastExcelWriter\Sheet

Show grid lines in the print area

Parameters

  • bool|null $bool

setPrintHorizontalCentered()


php
public function setPrintHorizontalCentered(?bool $value = true): avadim\FastExcelWriter\Sheet

Center the print area horizontally

Parameters

  • bool|null $value

setPrintLeftColumns()


php
public function setPrintLeftColumns(string $range): avadim\FastExcelWriter\Sheet

Set left columns to repeat on every printed page

Parameters

  • string $range

setPrintRowAndColumnHeading()


php
public function setPrintRowAndColumnHeading(?bool $bool = true): avadim\FastExcelWriter\Sheet

Print row and column headings in the printout

Parameters

  • bool|null $bool

setPrintTitles()


php
public function setPrintTitles(?string $rowsAtTop, 
                               ?string $colsAtLeft = null): avadim\FastExcelWriter\Sheet

Set rows to repeat at top and columns to repeat at left when printing

Parameters

  • string|null $rowsAtTop
  • string|null $colsAtLeft

setPrintTopRows()


php
public function setPrintTopRows(string $range): avadim\FastExcelWriter\Sheet

Set top rows to repeat on every printed page

Parameters

  • string $range

setPrintVerticalCentered()


php
public function setPrintVerticalCentered(?bool $value = true): avadim\FastExcelWriter\Sheet

Center the print area vertically

Parameters

  • bool|null $value

setRowDataStyle()


php
public function setRowDataStyle($rowRange, 
                                $style): avadim\FastExcelWriter\Sheet

Style are applied only to non-empty cells in a row (or row range)

Parameters

  • int|string|array $rowRange
  • array|Style $style

Examples

php
$sheet->setRowDataStyle(3, ['height' = 20]); // options for row number 3
$sheet->setRowDataStyle('2:5', ['font-color' = '#f00']); // options for range of rows

setRowDataStyleArray()


php
public function setRowDataStyleArray(array $rowStyles): avadim\FastExcelWriter\Sheet

Styles are applied only to non-empty cells in a rows

Parameters

  • array $rowStyles

Examples

php
$sheet->setRowDataStyleArray([3 => $style1, 5 => $style2]); // styles for rows 3 and 5

setRowHeight()


php
public function setRowHeight($rowNum, $height): avadim\FastExcelWriter\Sheet

Height of a specific row

Parameters

  • $rowNum
  • $height

setRowHeights()


php
public function setRowHeights(array $heights): avadim\FastExcelWriter\Sheet

Multiple rows height

Parameters

  • array $heights

setRowHidden()


php
public function setRowHidden($rowNum): avadim\FastExcelWriter\Sheet

Hide a specific row

Parameters

  • int|array $rowNum

setRowOutlineLevel()


php
public function setRowOutlineLevel($rowNum, int $outlineLevel, 
                                   ?bool $collapsed = null): avadim\FastExcelWriter\Sheet

Set an outline level for a specific row or range of rows

Parameters

  • int|array|string $rowNum
  • int $outlineLevel
  • bool|null $collapsed

Examples

php
setRowOutlineLevel(5, 1)
setRowOutlineLevel([5, 6, 7], 1)
setRowOutlineLevel('5:7', 1)

setRowStyle()


php
public function setRowStyle($rowRange, $style): avadim\FastExcelWriter\Sheet

The style is applied to the entire sheet row (even if it is empty)

Parameters

  • int|string|array $rowRange
  • array|Style $style

Examples

php
$sheet->setRowStyle(3, ['height' = 20]); // options for row number 3
$sheet->setRowStyle('2:5', ['font-color' = '#f00']); // options for range of rows

setRowStyleArray()


php
public function setRowStyleArray(array $rowStyles): avadim\FastExcelWriter\Sheet

Styles are applied to the entire sheet row (even if it is empty)

Parameters

  • array $rowStyles

Examples

php
$sheet->setRowStyleArray([3 => $style1, 5 => $style2]); // styles for rows 3 and 5

setRowVisible()


php
public function setRowVisible($rowNum, 
                              bool $visible): avadim\FastExcelWriter\Sheet

Hide/show a specific row

Parameters

  • int|array $rowNum
  • bool $visible

setShowGridLines()


php
public function setShowGridLines(bool $flag): void

Turn on/off grid lines

Parameters

  • bool $flag

setStateHidden()


php
public function setStateHidden(): avadim\FastExcelWriter\Sheet

Make the sheet hidden

Parameters

None


setStateVeryHidden()


php
public function setStateVeryHidden(): avadim\FastExcelWriter\Sheet

Make the sheet very hidden

Parameters

None


setStateVisible()


php
public function setStateVisible(): avadim\FastExcelWriter\Sheet

Make the sheet visible

Parameters

None


setStyle()


php
public function setStyle(string $cellAddress, $style, 
                         ?bool $mergeStyles = false): avadim\FastExcelWriter\Sheet

Alias for 'setCellStyle()'

Parameters

  • string $cellAddress
  • array|Style $style
  • bool|null $mergeStyles

setTabColor()


php
public function setTabColor(?string $color): avadim\FastExcelWriter\Sheet

Set color for the sheet tab

Parameters

  • string|null $color

setTopLeftCell()


php
public function setTopLeftCell($cellAddress): avadim\FastExcelWriter\Sheet

Set the top left cell for writing

Parameters

  • string|array $cellAddress

Examples

php
$sheet->setTopLeftCell('C3');
$sheet->writeRow([11, 22, 33]); // Will be written in cells C3, D3, E3
$sheet->setTopLeftCell('G7');
$sheet->writeRow([44, 55]); // Will be written in cells G7, H7

setValue()


php
public function setValue($cellAddress, $value, 
                         $style): avadim\FastExcelWriter\Sheet

Set a value to the single cell or to the cell range

Parameters

  • string|array $cellAddress
  • mixed $value
  • array|Style|null $style

Examples

php
$sheet->setValue('B5', $value);
$sheet->setValue('B5:C7', $value, $style);
$sheet->setValue(['col' => 2, 'row' => 5], $value, $style);
$sheet->setValue([2, 5], $value);

skipRow()


php
public function skipRow(?int $rowCount = 1): avadim\FastExcelWriter\Sheet

Skip rows

Parameters

  • int|null $rowCount

unprotect()


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

Unprotect sheet

Parameters

None


withHeadings()


php
public function withHeadings(?array $headers = [], ?array $rowStyle = [], 
                             ?array $colStyles = []): SheetWriter

Set headings for the sheet

Naming. The wrapper uses withHeadings() to match the Laravel ecosystem convention (as in maatwebsite/excel). The underlying writer has no withHeader(); it writes a header row imperatively via writeHeader(). withHeadings() instead defers the headings and writes them when the data is exported.

Without $headers the headings are the keys of the first record; if a mapping() is set, the keys of the mapped record are used. With $headers as key => title pairs the rows are rearranged by the keys.

Parameters

  • array|null $headers
  • array|null $rowStyle
  • array|null $colStyles

withLastCell()


php
public function withLastCell(): avadim\FastExcelWriter\Sheet

Select the last written cell for applying

Parameters

None


withLastRow()


php
public function withLastRow(): avadim\FastExcelWriter\Sheet

Select the last written row for applying

Parameters

None


withRange()


php
public function withRange($range): avadim\FastExcelWriter\Sheet

Select a custom range for applying

Parameters

  • array|string $range

writeArray()


php
public function writeArray(array $rowArray = [], 
                           $rowStyle): avadim\FastExcelWriter\Sheet

Write values from a two-dimensional array (alias of writeRows)

Parameters

  • array $rowArray -- Array of rows
  • array|Style|null $rowStyle -- Style applied to each row

writeArrayTo()


php
public function writeArrayTo($topLeftCell, 
                             array $data): avadim\FastExcelWriter\Sheet

Write 2d array from the specified cell

Parameters

  • $topLeftCell
  • array $data

writeCell()


php
public function writeCell($value, 
                          ?array $styles = null): avadim\FastExcelWriter\Sheet

Write value to the current cell and move a pointer to the next cell in the row

Parameters

  • mixed $value
  • array|null $styles

writeCells()


php
public function writeCells(array $values, 
                           ?array $cellStyles = null): avadim\FastExcelWriter\Sheet

Write several values into cells of one row

Parameters

  • array $values
  • array|null $cellStyles

writeData()


php
public function writeData($data, $rowStyle, 
                          ?array $colStyles = null): SheetWriter

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

Parameters

  • iterable|callable $data
  • array|Style|null $rowStyle
  • array|null $colStyles

writeHeader()


php
public function writeHeader(array $header, ?array $rowStyle = null, 
                            ?array $colStyles = []): avadim\FastExcelWriter\Sheet

Write a header row with optional styles and formats for columns

Parameters

  • array $header
  • array|null $rowStyle
  • array|null $colStyles

Examples

php
$sheet->writeHeader(['title1', 'title2', 'title3']); // texts for cells of header
$sheet->writeHeader(['title1' => '@text', 'title2' => 'YYYY-MM-DD', 'title3' => ['format' => ..., 'font' => ...]]); // texts and formats of columns
$sheet->writeHeader($cellValues, $rowStyle, $colStyles); // texts and formats of columns and options of row

writeRow()


php
public function writeRow(array $rowValues = [], $rowStyle, 
                         ?array $cellStyles = null): SheetWriter

Write values to the current row

Parameters

  • array $rowValues
  • array|Style|null $rowStyle
  • array|null $cellStyles

writeRows()


php
public function writeRows(array $rowArray = [], 
                          ?array $rowStyle = null): avadim\FastExcelWriter\Sheet

Write several rows from a two-dimensional array

Parameters

  • array $rowArray -- Array of rows
  • array|null $rowStyle -- Style applied to each row

writeTo()


php
public function writeTo($cellAddress, $value, $style, 
                        ?int $mergeFlag = 0): avadim\FastExcelWriter\Sheet

Write value to the specified cell and move a pointer to the next cell in the row

Parameters

  • string|array $cellAddress
  • mixed $value
  • array|Style|null $style
  • int|null $mergeFlag

Examples

php
$sheet->writeTo('B5', $value); // write to single cell
$sheet->writeTo(['col' => 2, 'row' => 5], $value); // address as an array
$sheet->writeTo([2, 5], $value); // address as an array
$sheet->writeTo('B5:C7', $value); // write a value to merged cells
$sheet->writeTo('B5:C7', $value, $styles, Sheet:MERGE_NO_CHECK); // don't check for intersection of merged cells

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.