PHP Class Piwik\DataTable\Renderer\Csv

When rendered using the default settings, a CSV report has the following characteristics: The first record contains headers for all the columns in the report. All rows have the same number of columns. The default field delimiter string is a comma (,). Formatting and layout are ignored.
Inheritance: extends Piwik\DataTable\Renderer
Show file Open project: piwik/piwik Class Usage Examples

Public Properties

Property Type Description
$convertToUnicode boolean Converts the content to unicode so that UTF8 characters (eg. chinese) can be imported in Excel
$exportIdSubtable boolean idSubtable will be exported in a column called 'idsubdatatable'
$exportMetadata boolean 'metadata' columns will be exported, prefixed by 'metadata_'
$lineEnd string Line end
$separator string Column separator

Public Methods

Method Description
render ( ) : string Computes the dataTable output and returns the string/binary
setConvertToUnicode ( $bool ) Enables / Disables unicode converting
setSeparator ( $separator ) Sets the column separator

Protected Methods

Method Description
formatFormulas ( $value )
formatValue ( mixed $value ) : string Formats/Escapes the given value
removeFirstPercentSign ( $value ) : mixed
renderDataTable ( DataTable | Piwik\DataTable\Simple $table, array &$allColumns = [] ) : string Converts the output of the given simple data table
renderDataTableMap ( Piwik\DataTable\Map $table, array &$allColumns = [] ) : string Computes the output of the given data table array
renderHeader ( ) Sends the http headers for csv file
renderTable ( DataTable | array $table, array &$allColumns = [] ) : string Computes the output of the given data table

Private Methods

Method Description
buildCsvString ( $allColumns, $csv ) : array
convertToUnicode ( $str ) : string
flattenColumnArray ( $columns, &$csvRow = [], $csvColumnNameTemplate = '%s' ) Flattens an array of column values so they can be outputted as CSV (which does not support nested structures).
getCsvColumnName ( $name )
getHeaderLine ( array $columnMetrics ) : array Returns the CSV header line for a set of metrics. Will translate columns if desired.
makeArrayFromDataTable ( $table, &$allColumns ) : array

Method Details

formatFormulas() protected method

protected formatFormulas ( $value )

formatValue() protected method

Formats/Escapes the given value
protected formatValue ( mixed $value ) : string
$value mixed
return string

removeFirstPercentSign() protected method

protected removeFirstPercentSign ( $value ) : mixed
$value
return mixed

render() public method

Computes the dataTable output and returns the string/binary
public render ( ) : string
return string

renderDataTable() protected method

Converts the output of the given simple data table
protected renderDataTable ( DataTable | Piwik\DataTable\Simple $table, array &$allColumns = [] ) : string
$table Piwik\DataTable | Piwik\DataTable\Simple
$allColumns array
return string

renderDataTableMap() protected method

Computes the output of the given data table array
protected renderDataTableMap ( Piwik\DataTable\Map $table, array &$allColumns = [] ) : string
$table Piwik\DataTable\Map
$allColumns array
return string

renderHeader() protected method

Sends the http headers for csv file
protected renderHeader ( )

renderTable() protected method

Computes the output of the given data table
protected renderTable ( DataTable | array $table, array &$allColumns = [] ) : string
$table Piwik\DataTable | array
$allColumns array
return string

setConvertToUnicode() public method

Enables / Disables unicode converting
public setConvertToUnicode ( $bool )
$bool

setSeparator() public method

Sets the column separator
public setSeparator ( $separator )
$separator

Property Details

$convertToUnicode public property

Converts the content to unicode so that UTF8 characters (eg. chinese) can be imported in Excel
public bool $convertToUnicode
return boolean

$exportIdSubtable public property

idSubtable will be exported in a column called 'idsubdatatable'
public bool $exportIdSubtable
return boolean

$exportMetadata public property

'metadata' columns will be exported, prefixed by 'metadata_'
public bool $exportMetadata
return boolean

$lineEnd public property

Line end
public string $lineEnd
return string

$separator public property

Column separator
public string $separator
return string