Export to CSV

Get started #

CSVExportable trait allows you to export datastores to CSV files. Alternatively, you could use BigSpreadsheetExportable trait which also has exportToCSV method and optimizes for huge export files.

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

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'

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.