class Excel (View source)

Class Excel

Constants

TYPE_STRING

TYPE_INT

TYPE_DOUBLE

TYPE_TIMESTAMP

SKIP_NONE

SKIP_EMPTY_ROW

SKIP_EMPTY_CELLS

GRIDLINES_HIDE_ALL

GRIDLINES_SHOW_SCREEN

GRIDLINES_SHOW_PRINT

GRIDLINES_SHOW_ALL

Methods

__construct(array $config)

Excel constructor.

fileName(string $fileName, string $sheetName = 'Sheet1')

File Name

constMemory(string $fileName, string $sheetName = 'Sheet1')

Const memory model

addSheet(string|null $sheetName)

Add a new worksheet to a workbook.

checkoutSheet(string $sheetName)

Checkout worksheet

header(array $header)

Insert data on the first line of the worksheet

data(array $data)

Insert data on the worksheet

string
output()

Generate file

resource
getHandle()

Get file resource

autoFilter(string $range)

Auto filter on the worksheet

insertText(int $row, int $column, int|string|float $data, string $format = null, resource|null $formatHandle = null)

Insert data on the cell

insertDate(int $row, int $column, int $timestamp, string $format = null, resource|null $formatHandle = null)

Insert date on the cell

insertChart(int $row, int $column, resource $chartResource)

Insert chart on the cell

insertUrl(int $row, int $column, string $url, resource|null $formatHandle = null)

Insert url on the cell

insertImage(int $row, int $column, string $imagePath, float $width = 1, float $height = 1)

Insert image on the cell

insertFormula(int $row, int $column, string $formula)

Insert Formula on the cell

MergeCells(string $range, string $data)

Merge cells

setColumn(string $range, float $cellWidth, resource|null $formatHandle = null)

Set column cells width or format

setRow(string $range, float $cellHeight, resource|null $formatHandle = null)

Set row cells height or format

openFile(string $fileName)

Open xlsx file

openSheet(string $sheetName = null, int $skipFlag = 0x0)

Open sheet

setType(array $types)

Set row cell data type

array
getSheetData()

Read values from the sheet

array
nextRow()

Read values from the sheet

void
nextCellCallback(callable $callback, string $sheetName = null)

Next Cell In Callback

freezePanes(int $row, int $column)

Freeze panes

gridline(int $option)

Gridline

zoom(int $scale)

Worksheet zoom

Details

__construct(array $config)

Excel constructor.

Parameters

array $config

Excel fileName(string $fileName, string $sheetName = 'Sheet1')

File Name

Parameters

string $fileName
string $sheetName

Return Value

Excel

Excel constMemory(string $fileName, string $sheetName = 'Sheet1')

Const memory model

Parameters

string $fileName
string $sheetName

Return Value

Excel

Excel addSheet(string|null $sheetName)

Add a new worksheet to a workbook.

The worksheet name must be a valid Excel worksheet name, i.e. it must be less than 32 character and it cannot contain any of the characters:

/ \ [ ] : * ?

In addition, you cannot use the same, case insensitive, $sheetName for more than one worksheet.

Parameters

string|null $sheetName

Return Value

Excel

Excel checkoutSheet(string $sheetName)

Checkout worksheet

Parameters

string $sheetName

Return Value

Excel

Excel header(array $header)

Insert data on the first line of the worksheet

Parameters

array $header

Return Value

Excel

Excel data(array $data)

Insert data on the worksheet

Parameters

array $data

Return Value

Excel

string output()

Generate file

Return Value

string

resource getHandle()

Get file resource

Return Value

resource

Excel autoFilter(string $range)

Auto filter on the worksheet

Parameters

string $range

Return Value

Excel

Excel insertText(int $row, int $column, int|string|float $data, string $format = null, resource|null $formatHandle = null)

Insert data on the cell

Parameters

int $row
int $column
int|string|float $data
string $format
resource|null $formatHandle

Return Value

Excel

Excel insertDate(int $row, int $column, int $timestamp, string $format = null, resource|null $formatHandle = null)

Insert date on the cell

Parameters

int $row
int $column
int $timestamp
string $format
resource|null $formatHandle

Return Value

Excel

Excel insertChart(int $row, int $column, resource $chartResource)

Insert chart on the cell

Parameters

int $row
int $column
resource $chartResource

Return Value

Excel

Excel insertUrl(int $row, int $column, string $url, resource|null $formatHandle = null)

Insert url on the cell

Parameters

int $row
int $column
string $url
resource|null $formatHandle

Return Value

Excel

Excel insertImage(int $row, int $column, string $imagePath, float $width = 1, float $height = 1)

Insert image on the cell

Parameters

int $row
int $column
string $imagePath
float $width
float $height

Return Value

Excel

Excel insertFormula(int $row, int $column, string $formula)

Insert Formula on the cell

Parameters

int $row
int $column
string $formula

Return Value

Excel

Excel MergeCells(string $range, string $data)

Merge cells

Parameters

string $range
string $data

Return Value

Excel

Excel setColumn(string $range, float $cellWidth, resource|null $formatHandle = null)

Set column cells width or format

Parameters

string $range
float $cellWidth
resource|null $formatHandle

Return Value

Excel

Excel setRow(string $range, float $cellHeight, resource|null $formatHandle = null)

Set row cells height or format

Parameters

string $range
float $cellHeight
resource|null $formatHandle

Return Value

Excel

Excel openFile(string $fileName)

Open xlsx file

Parameters

string $fileName

Return Value

Excel

Excel openSheet(string $sheetName = null, int $skipFlag = 0x0)

Open sheet

default open first sheet

Parameters

string $sheetName
int $skipFlag

Return Value

Excel

Excel setType(array $types)

Set row cell data type

Parameters

array $types

Return Value

Excel

array getSheetData()

Read values from the sheet

Return Value

array

array nextRow()

Read values from the sheet

Return Value

array

void nextCellCallback(callable $callback, string $sheetName = null)

Next Cell In Callback

Parameters

callable $callback

function(int $row, int $cell, string $data)

string $sheetName

sheet name

Return Value

void

Excel freezePanes(int $row, int $column)

Freeze panes

freezePanes(1, 0); // Freeze the first row. freezePanes(0, 1); // Freeze the first column. freezePanes(1, 1); // Freeze first row/column.

Parameters

int $row
int $column

Return Value

Excel

Excel gridline(int $option)

Gridline

Display or hide screen and print gridlines using one of the values of

\Vtiful\Kernel\Excel::GRIDLINES_HIDE_ALL \Vtiful\Kernel\Excel::GRIDLINES_SHOW_ALL \Vtiful\Kernel\Excel::GRIDLINES_SHOW_PRINT \Vtiful\Kernel\Excel::GRIDLINES_SHOW_SCREEN

Excel default is that the screen gridlines are on and the printed worksheet is off.

Parameters

int $option

Return Value

Excel

Excel zoom(int $scale)

Worksheet zoom

Set the worksheet zoom factor in the range 10 <= zoom <= 400:

Parameters

int $scale

Return Value

Excel