CSVExport
extends ExportBase
in package
Class to export data to CSV format.
Tags
Table of Contents
- LIST_LIMIT = 1000
- $csv : array<string|int, mixed>
- Contains the CSV data in array format
- $delimiter : string
- Text delimiter value
- $fileName : string
- $separator : string
- Separator value
- addBusinessDocPage() : bool
- Adds the fields form the business document, merging model and line data.
- addListModelPage() : bool
- Adds a new page with a table listing the model data.
- addModelPage() : bool
- Adds a new page with the model data.
- addTablePage() : bool
- Adds a new page with the table.
- getDelimiter() : string
- Returns the received text delimiter assigned
- getDoc() : string
- Return the full document.
- getSeparator() : string
- Returns the assigned separator
- newDoc() : mixed
- Blank document.
- setDelimiter() : mixed
- Assigns the received text delimiter By default it will use '"' quotes.
- setOrientation() : mixed
- Sets default orientation.
- setSeparator() : mixed
- Assigns the received separator.
- show() : mixed
- Set headers and output document content to response.
- writeData() : mixed
- Fills an array with the CSV data.
- getColumnAlignments() : array<string|int, mixed>
- getColumnTitles() : array<string|int, mixed>
- getColumnWidgets() : array<string|int, mixed>
- getCursorData() : array<string|int, mixed>
- getCursorRawData() : array<string|int, mixed>
- getDocumentFormat() : FormatoDocumento
- getFileName() : string
- getModelColumnsData() : array<string|int, mixed>
- getModelFields() : array<string|int, mixed>
- setFileName() : mixed
- toolBox() : ToolBox
- writeHeader() : mixed
Constants
LIST_LIMIT
public
mixed
LIST_LIMIT
= 1000
Properties
$csv
Contains the CSV data in array format
private
array<string|int, mixed>
$csv
= []
$delimiter
Text delimiter value
private
string
$delimiter
= '"'
$fileName
private
string
$fileName
$separator
Separator value
private
string
$separator
= ';'
Methods
addBusinessDocPage()
Adds the fields form the business document, merging model and line data.
public
addBusinessDocPage(BusinessDocument $model) : bool
Parameters
- $model : BusinessDocument
Return values
bool —addListModelPage()
Adds a new page with a table listing the model data.
public
addListModelPage(ModelClass $model, array<string|int, DataBaseWhere> $where, array<string|int, mixed> $order, int $offset, array<string|int, mixed> $columns[, string $title = '' ]) : bool
Parameters
- $model : ModelClass
- $where : array<string|int, DataBaseWhere>
- $order : array<string|int, mixed>
- $offset : int
- $columns : array<string|int, mixed>
- $title : string = ''
Return values
bool —addModelPage()
Adds a new page with the model data.
public
addModelPage(ModelClass $model, array<string|int, mixed> $columns[, string $title = '' ]) : bool
Parameters
- $model : ModelClass
- $columns : array<string|int, mixed>
- $title : string = ''
Return values
bool —addTablePage()
Adds a new page with the table.
public
addTablePage(array<string|int, mixed> $headers, array<string|int, mixed> $rows[, array<string|int, mixed> $options = [] ][, string $title = '' ]) : bool
Parameters
- $headers : array<string|int, mixed>
- $rows : array<string|int, mixed>
- $options : array<string|int, mixed> = []
- $title : string = ''
Return values
bool —getDelimiter()
Returns the received text delimiter assigned
public
getDelimiter() : string
Return values
string —getDoc()
Return the full document.
public
getDoc() : string
Return values
string —getSeparator()
Returns the assigned separator
public
getSeparator() : string
Return values
string —newDoc()
Blank document.
public
newDoc(string $title, int $idformat, string $langcode) : mixed
Parameters
- $title : string
- $idformat : int
- $langcode : string
Return values
mixed —setDelimiter()
Assigns the received text delimiter By default it will use '"' quotes.
public
setDelimiter(string $del) : mixed
Parameters
- $del : string
Return values
mixed —setOrientation()
Sets default orientation.
public
setOrientation(string $orientation) : mixed
Parameters
- $orientation : string
Return values
mixed —setSeparator()
Assigns the received separator.
public
setSeparator(string $sep) : mixed
By default it will use ';' semicolons.
Parameters
- $sep : string
Return values
mixed —show()
Set headers and output document content to response.
public
show(Response &$response) : mixed
Parameters
- $response : Response
Return values
mixed —writeData()
Fills an array with the CSV data.
public
writeData(array<string|int, mixed> $data[, array<string|int, mixed> $fields = [] ]) : mixed
Parameters
- $data : array<string|int, mixed>
- $fields : array<string|int, mixed> = []
Return values
mixed —getColumnAlignments()
protected
getColumnAlignments(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>
Return values
array<string|int, mixed> —getColumnTitles()
protected
getColumnTitles(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>
Return values
array<string|int, mixed> —getColumnWidgets()
protected
getColumnWidgets(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>
Return values
array<string|int, mixed> —getCursorData()
protected
getCursorData(array<string|int, ModelClass> $cursor, array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
- $cursor : array<string|int, ModelClass>
- $columns : array<string|int, mixed>
Return values
array<string|int, mixed> —getCursorRawData()
protected
getCursorRawData(array<string|int, ModelClass> $cursor[, array<string|int, mixed> $fields = [] ]) : array<string|int, mixed>
Parameters
- $cursor : array<string|int, ModelClass>
- $fields : array<string|int, mixed> = []
Return values
array<string|int, mixed> —getDocumentFormat()
protected
getDocumentFormat(BusinessDocument $model) : FormatoDocumento
Parameters
- $model : BusinessDocument
Return values
FormatoDocumento —getFileName()
protected
getFileName() : string
Return values
string —getModelColumnsData()
protected
getModelColumnsData(ModelClass $model, array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
- $model : ModelClass
- $columns : array<string|int, mixed>
Return values
array<string|int, mixed> —getModelFields()
protected
getModelFields(ModelClass $model) : array<string|int, mixed>
Parameters
- $model : ModelClass
Return values
array<string|int, mixed> —setFileName()
protected
setFileName(string $name) : mixed
Parameters
- $name : string
Return values
mixed —toolBox()
protected
toolBox() : ToolBox
Tags
Return values
ToolBox —writeHeader()
private
writeHeader(array<string|int, mixed> $fields) : mixed
Parameters
- $fields : array<string|int, mixed>