Export to CSV

Get started #

CSVExportable trait allows you to export datastores to CSV files.

class MyReport extends \koolreport\KoolReport
    use \koolreport\excel\CSVExportable;

CSV exporting options #

The 'delimiter' or 'fieldSeparator' option defines a string used to separate columns in the exported CSV file. Default value is a comma. 'columns' option is an array defining a list of columns in the exported CSV file. Values could be either column indexes, column keys or column labels. if not specified, all columns are exported. "BOM" parameter takes boolean value, default is false, BOM determine whether exported CSV will use UTF8 Bit Order Mark (BOM).

$report = new MyReport;
$report->run()->exportToCSV('salesReport', array(
    'delimiter' => ';',
        0, 1, 2, 'column3', 'column4'