Get started

Get data from Excel #

ExcelDataSource help you to get data from your current Microsoft Excel file.

Settings #

Nametypedefaultdescription
classstringMust set to '\koolreport\datasources\ExcelDataSource'
filePathstringThe full file path to your Excel file.
charsetstring"utf8"Charset of your Excel file
firstRowDatabooleanfalseWhether the first row is data. Normally the first row contain the field name so default value of this property is false.
sheetNamestringnullSet a sheet name to load instead of all sheets. (version >= 2.1.0)
sheetIndexnumbernullSet a sheet index to load instead of all sheets. If both sheetName and sheetIndex are set, priority is given to sheetName first. (version >= 2.1.0)

Example #

class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "sale_source"=>array(
                    "class"=>"\koolreport\excel\ExcelDataSource",
                    "filePath"=>"../data/my_file.xlsx",
                    "charset"=>"utf8",
                    "firstRowData"=>false,//Set true if first row is data and not the header,
                    "sheetName"=>"sheet1", // (version >= 2.1.0)
                    "sheetIndex"=>0, // (version >= 2.1.0)
                )
            )
        );
    }

    public function setup()
    {
        $this->src('sale_source')
        ->pipe(...)
    }
}

Save file vs push file to browser #

After exporting, you have two options to do with the file. First, you can save the file to local drive and can use it later for example attaching file to email. Second, you can push to file to browser for user to download.

To save file, you do:

$report->run()->exportToExcel(...)->saveAs("../storage/myreport.xlsx"); // State the path of file

To push file to browser, you do:

$report->run()->exportToExcel()->toBrowser("myreport.xlsx"); // Input the filename

Get data from huge xlsx, ods and csv files (version >= 7.0.0) #

BigSpreadsheetDataSource helps you to get data from huge spreadsheet files of type xlsx, ods or csv.

Settings #

Nametypedefaultdescription
classstringMust set to '\koolreport\datasources\BigSpreadsheetDataSource'
filePathstringThe full file path to your spreadsheet file.
fileTypestring"xlsx", "ods" or "csv". Only needed if file extension is different from its type.
charsetstring"utf8"Charset of your spreadsheet file
firstRowDatabooleanfalseWhether the first row is data. Normally the first row contain the field name so default value of this property is false.
fieldSeparatorstring,Used for setting a csv file's delimiter
sheetNamestringnullSet a sheet name to load instead of all sheets. Not applicable for csv files.
sheetIndexnumbernullSet a sheet index to load instead of all sheets. If both sheetName and sheetIndex are set, priority is given to sheetName first. Not applicable for csv files.

Example #

class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "sale_source"=>array(
                    "class"=>"\koolreport\excel\BigSpreadsheetDataSource",
                    "filePath"=>"../data/my_file.xlsx",
                    "firstRowData"=>false,//Set true if first row is data and not the header,
                    "sheetName"=>"sheet1",
                    "sheetIndex"=>0,
                )
            )
        );
    }

    public function setup()
    {
        $this->src('sale_source')
        ->pipe(...)
    }
}

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.