Phpxforms documentation

ExporterXlsx extends Exporter
in package

Export to Xlsx

Table of Contents

Constants

VERSION  = 0.87
UNITS  = 'pt'
XML_HEADER  = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
BORDER_MEDIUM  = 2
BORDER_THICK  = 4
FONT_SIZE  = '10pt'

Properties

$borderTypes  : array<string, string>
$defColor  : string
$defaultStyle  : array<string, mixed>
$fileName  : string
$sheets  : array<string|int, Sheet>
$styles  : array<string, mixed>

Methods

__construct()  : mixed
Set output file name
addSheet()  : void
Insert sheet, throws error if name exist
addStyle()  : void
Insert new content style
compile()  : string
Generate Xlsx file
convertColor()  : string
Convert color format
convertSize()  : float
Convert between different measure systems
download()  : void
Create download content
getSheets()  : array<string|int, Sheet>
Return array of Sheet
getVersion()  : string
Return version
insertSheet()  : Sheet
Create new data sheet, if name already exist rename
setDefault()  : void
Set default style
toAlpha()  : string
Convert column number to xlsx alphanumeric
xmlEntities()  : string
Convert XML entities
checkUniqueName()  : string
Check if chosen name is unique - if not change it
convertColSize()  : float
Try to convert metric units to ms unit
createTemp()  : string
Create a temporary file in the temporary
fileStyles()  : string
XLSX style, can't be empty
prepareBorder()  : array<string, mixed>
Convert border settings
fileContentTypes()  : string
XLSX basic info file
fileRelationships()  : string
Additional doc info
fileSheet()  : string
Data sheet
fileWorkbook()  : string
XLSX workbook info
getBorderStyle()  : string
Create border style and convert border width to 3 types used in xlsx
getCell()  : string
Get table cell
getCellValue()  : string
Get table cell value
getFontStyle()  : string
Create font style for xlsx
getSheetRelationships()  : array<string, string>
Create sheet list for xlsx
reshuffleStyleBorder()  : array<string, mixed>
Reformat style for borders
reshuffleStyles()  : array<string, mixed>
Prepare styles for xlsx structure
sortStyle()  : void
Reorder style

Constants

XML_HEADER

protected string XML_HEADER = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"

Properties

$borderTypes

public static array<string, string> $borderTypes = ['left' => 'LEFT', 'right' => 'RIGHT', 'top' => 'TOP', 'bottom' => 'BOTTOM']

$defColor

public static string $defColor = '#000000'

$defaultStyle

protected array<string, mixed> $defaultStyle = []

$styles

protected array<string, mixed> $styles = []

Methods

__construct()

Set output file name

public __construct(string $fileName) : mixed
Parameters
$fileName : string
Tags
throws
RuntimeException

addSheet()

Insert sheet, throws error if name exist

public addSheet(Sheet $sheet) : void
Parameters
$sheet : Sheet
Tags
throws
InvalidArgumentException

addStyle()

Insert new content style

public addStyle(string $mark[, array<string, mixed> $font = [] ][, array<string, mixed> $cell = [] ][, int|null $height = null ]) : void
Parameters
$mark : string
$font : array<string, mixed> = []
$cell : array<string, mixed> = []
$height : int|null = null
Tags
throws
InvalidArgumentException

compile()

Generate Xlsx file

public compile() : string
Tags
throws
RuntimeException
Return values
string

convertColor()

Convert color format

public static convertColor(string $color) : string
Parameters
$color : string

color in #format

Return values
string

convertSize()

Convert between different measure systems

public static convertSize(string|float $num[, string $def = 'pt' ][, string|null $out = null ]) : float
Parameters
$num : string|float

Value

$def : string = 'pt'

Measure unit

$out : string|null = null

Measure unit

Tags
throws
InvalidArgumentException
Return values
float

download()

Create download content

public download() : void

getSheets()

Return array of Sheet

public getSheets() : array<string|int, Sheet>
Return values
array<string|int, Sheet>

getVersion()

Return version

public getVersion() : string
Return values
string

insertSheet()

Create new data sheet, if name already exist rename

public insertSheet([string $name = 'List' ]) : Sheet
Parameters
$name : string = 'List'
Return values
Sheet

setDefault()

Set default style

public setDefault([array<string, mixed> $font = [] ][, array<string, mixed> $cell = [] ][, int|null $height = null ]) : void
Parameters
$font : array<string, mixed> = []
$cell : array<string, mixed> = []
$height : int|null = null

toAlpha()

Convert column number to xlsx alphanumeric

public static toAlpha(int $num) : string
Parameters
$num : int
Return values
string

xmlEntities()

Convert XML entities

public static xmlEntities(string|float|int|null $val) : string
Parameters
$val : string|float|int|null
Return values
string

checkUniqueName()

Check if chosen name is unique - if not change it

protected checkUniqueName(string $newName[, int $i = 0 ]) : string
Parameters
$newName : string
$i : int = 0
Return values
string

convertColSize()

Try to convert metric units to ms unit

protected convertColSize(string|float $size) : float
Parameters
$size : string|float

(optimal - mm)

Return values
float

createTemp()

Create a temporary file in the temporary

protected createTemp() : string
Tags
throws
InvalidArgumentException
Return values
string

fileStyles()

XLSX style, can't be empty

protected fileStyles() : string
Return values
string

prepareBorder()

Convert border settings

protected prepareBorder(array<string, mixed> $cell) : array<string, mixed>
Parameters
$cell : array<string, mixed>
Return values
array<string, mixed>

fileContentTypes()

XLSX basic info file

private fileContentTypes() : string
Return values
string

fileRelationships()

Additional doc info

private fileRelationships(string $type, array<string, string> $data) : string
Parameters
$type : string
$data : array<string, string>
Return values
string

fileSheet()

Data sheet

private fileSheet(Sheet $sheet) : string
Parameters
$sheet : Sheet
Tags
throws
InvalidArgumentException
Return values
string

fileWorkbook()

XLSX workbook info

private fileWorkbook() : string
Return values
string

getBorderStyle()

Create border style and convert border width to 3 types used in xlsx

private getBorderStyle(string $elm[, array<string, mixed> $border = null ]) : string
Parameters
$elm : string
$border : array<string, mixed> = null
Return values
string

getCell()

Get table cell

private getCell(array<string, mixed>|string|float|int|null $col, int $num, int $line, int $j, string|null $class, array<string, int> $styles, array<int, array<int, int>> &$skipPlan, array<string, string> &$mergeCells) : string
Parameters
$col : array<string, mixed>|string|float|int|null
$num : int
$line : int
$j : int
$class : string|null
$styles : array<string, int>
$skipPlan : array<int, array<int, int>>
$mergeCells : array<string, string>
Return values
string

getCellValue()

Get table cell value

private getCellValue(string|float|int $val, int $num, int $line[, int|null $style = null ][, array<string, mixed>|null $col = null ]) : string
Parameters
$val : string|float|int
$num : int
$line : int
$style : int|null = null
$col : array<string, mixed>|null = null
Return values
string

getFontStyle()

Create font style for xlsx

private getFontStyle(array<string, mixed> $font) : string
Parameters
$font : array<string, mixed>
Return values
string

getSheetRelationships()

Create sheet list for xlsx

private getSheetRelationships() : array<string, string>
Return values
array<string, string>

reshuffleStyleBorder()

Reformat style for borders

private reshuffleStyleBorder(array<string, mixed> $cell) : array<string, mixed>
Parameters
$cell : array<string, mixed>
Return values
array<string, mixed>

reshuffleStyles()

Prepare styles for xlsx structure

private reshuffleStyles(array<int|string, mixed> $list) : array<string, mixed>
Parameters
$list : array<int|string, mixed>
Return values
array<string, mixed>

sortStyle()

Reorder style

private sortStyle(string|int $num, array<string, mixed>|string|null $item, string $type, array<string, mixed> &$list, array<int, array<string, string>> &$map) : void
Parameters
$num : string|int
$item : array<string, mixed>|string|null
$type : string
$list : array<string, mixed>
$map : array<int, array<string, string>>

        
On this page

Search results