PHP Class Kimai_Export_ExcelExporter

Author: Florian Lentsch ([email protected])
Inheritance: extends PHPExcel
显示文件 Open project: kimai/kimai Class Usage Examples

Public Properties

Property Type Description
$columns_dict array dictionary value: column name as in extensions/ki_export/templates/scripts/main.php key: true if active, else false
$customTimeformat string strftime format string for fields of type time
$exportData_arr array the data rows to be exported
$kga array Kimai Global Array

Protected Properties

Property Type Description
$COLUMN_CONFIG array Column configuration: columns_dict> => [ 'fieldName' => exportData_arr - defaults to the same field name as in $this->columns> 'type' => 'langLabel' => kga['lang'] - defaults to the same as the field name in $this->columns> 'sum' => boolean - if true, sums will be generated for this field ]
$activeColumns_arr array contains names (as in $this->columns_dict) of active columns
$anySumsWereAdded boolean true, if there are any active columns with sums, else false
$dateFormat string excel format string for fields of type date
$sheet PHPExcel_Worksheet the first (and only) worksheet
$timeFormat string excel format string for fields of type time

Public Methods

Method Description
render ( array $kga, array $exportData_arr, array $columns_dict, string $customTimeformat ) generates an .xlsx file containing time sheets to be exported the file will be sent to the browser for download/viewing

Protected Methods

Method Description
addCellBorders ( ) add cell borders
doLayouting ( ) do layouting (cell borders, font styles, background colors, cell sizing, page setup)
excelAddr ( integer $x, integer $y ) : string get excel field address by supplying coordinates (e.g. '1/1' becomes 'B2')
excelColumnAddr ( integer $n ) : string get excel column letter by index (e.g. '2' becomes 'C') using this over PHPExcels built-in methods, because they are partly 1-based instead of 0-based
excelRange ( $x1, $y1, $x2, $y2 ) : string get excel field range by supplying coordinates
formatDataRowsByType ( ) cell formatting (number/text/date .
formatHeaders ( ) format the headers (additional cell borders, background color, alignment)
formatSums ( ) format the sums row if there are any sums (borders and background color)
initialize ( ) initial PHPExcel settings; build $this->activeColumns_arr
renderExcel ( ) renders the excel and sends it to the browser
writeDataRows ( ) write the data rows for all active columns
writeHeaders ( ) write the headers for all active columns
writeSums ( ) write sums for active columns only if configured in self::$COLUMN_CONFIG

Method Details

addCellBorders() protected method

add cell borders
protected addCellBorders ( )

doLayouting() protected method

do layouting (cell borders, font styles, background colors, cell sizing, page setup)
protected doLayouting ( )

excelAddr() protected static method

get excel field address by supplying coordinates (e.g. '1/1' becomes 'B2')
protected static excelAddr ( integer $x, integer $y ) : string
$x integer horizontal coordinate
$y integer vertical coordinate
return string excel field address

excelColumnAddr() protected static method

get excel column letter by index (e.g. '2' becomes 'C') using this over PHPExcels built-in methods, because they are partly 1-based instead of 0-based
protected static excelColumnAddr ( integer $n ) : string
$n integer column index
return string excel column letter

excelRange() protected static method

get excel field range by supplying coordinates
protected static excelRange ( $x1, $y1, $x2, $y2 ) : string
return string excel field range

formatDataRowsByType() protected method

..) as configured in self::$COLUMN_CONFIG
protected formatDataRowsByType ( )

formatHeaders() protected method

format the headers (additional cell borders, background color, alignment)
protected formatHeaders ( )

formatSums() protected method

format the sums row if there are any sums (borders and background color)
protected formatSums ( )

initialize() protected method

initial PHPExcel settings; build $this->activeColumns_arr
protected initialize ( )

render() public method

generates an .xlsx file containing time sheets to be exported the file will be sent to the browser for download/viewing
public render ( array $kga, array $exportData_arr, array $columns_dict, string $customTimeformat )
$kga array Kimai Global Array
$exportData_arr array the data rows to be exported
$columns_dict array dictionary of columns: column name => active (true/false)
$customTimeformat string strftime format string for fields of type time (for dates $this->kga['conf']['date_format_1'] will be used)

renderExcel() protected method

renders the excel and sends it to the browser
protected renderExcel ( )

writeDataRows() protected method

write the data rows for all active columns
protected writeDataRows ( )

writeHeaders() protected method

write the headers for all active columns
protected writeHeaders ( )

writeSums() protected method

write sums for active columns only if configured in self::$COLUMN_CONFIG
protected writeSums ( )

Property Details

$COLUMN_CONFIG protected_oe static_oe property

Column configuration: columns_dict> => [ 'fieldName' => exportData_arr - defaults to the same field name as in $this->columns> 'type' => 'langLabel' => kga['lang'] - defaults to the same as the field name in $this->columns> 'sum' => boolean - if true, sums will be generated for this field ]
protected static array $COLUMN_CONFIG
return array

$activeColumns_arr protected_oe property

contains names (as in $this->columns_dict) of active columns
protected array $activeColumns_arr
return array

$anySumsWereAdded protected_oe property

true, if there are any active columns with sums, else false
protected bool $anySumsWereAdded
return boolean

$columns_dict public_oe property

dictionary value: column name as in extensions/ki_export/templates/scripts/main.php key: true if active, else false
public array $columns_dict
return array

$customTimeformat public_oe property

strftime format string for fields of type time
public string $customTimeformat
return string

$dateFormat protected_oe property

excel format string for fields of type date
protected string $dateFormat
return string

$exportData_arr public_oe property

the data rows to be exported
public array $exportData_arr
return array

$kga public_oe property

Kimai Global Array
public array $kga
return array

$sheet protected_oe property

the first (and only) worksheet
protected PHPExcel_Worksheet $sheet
return PHPExcel_Worksheet

$timeFormat protected_oe property

excel format string for fields of type time
protected string $timeFormat
return string