- Get data from Excel
- Save file vs push file to browser
- Get data from huge xlsx, ods and csv files (version >= 7.0.0)
Get started
Get data from Excel #
ExcelDataSource
help you to get data from your current Microsoft Excel file.
Settings #
Name | type | default | description |
---|---|---|---|
class | string | Must set to '\koolreport\datasources\ExcelDataSource' | |
filePath | string | The full file path to your Excel file. | |
charset | string | "utf8" | Charset of your Excel file |
firstRowData | boolean | false | Whether the first row is data. Normally the first row contain the field name so default value of this property is false. |
sheetName | string | null | Set a sheet name to load instead of all sheets. (version >= 2.1.0) |
sheetIndex | number | null | Set 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 #
Name | type | default | description |
---|---|---|---|
class | string | Must set to '\koolreport\datasources\BigSpreadsheetDataSource' | |
filePath | string | The full file path to your spreadsheet file. | |
fileType | string | "xlsx", "ods" or "csv". Only needed if file extension is different from its type. | |
charset | string | "utf8" | Charset of your spreadsheet file |
firstRowData | boolean | false | Whether the first row is data. Normally the first row contain the field name so default value of this property is false. |
fieldSeparator | string | , | Used for setting a csv file's delimiter |
sheetName | string | null | Set a sheet name to load instead of all sheets. Not applicable for csv files. |
sheetIndex | number | null | Set 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.