Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Hi Daniel,
For date/datetime columns, please use "displayFormat" to display its value in that format. The "format" meta is used to instruct report to understand the date column's values in which format. Here's an example:
->pipe(new ColumnMeta(array(
"column_1" => array(
"format" => "Y-m-d H:i:s", //i.e date value from datasource has format like "2020-09-22 00:00:00"
"displayFormat" => "d/m/Y", //we want to show this column as "22/09/2020" in the report
)
)))
Let us know how it works for you. Thanks!
Hi Daniel,
Unfortunately at the moment the library used by exportToXLSX is somewhat limited with formatting cell because all cell values are inserted as general values. If you must use exportToXLSX, which is faster and supports exportint huge files, instead of exportToExcel, which is more flexible, I would suggest formatting the values before saving them to datastore like this:
->pipe(new \koolreport\processes\Map(array(
"{value}" => function($row) {
$row["formattedDate1"] = myFormatDateFunc($row["date1"]); //use php code to change your date format to a new one, says Y-m-d to d/m/Y
return $row;
)
)))
->pipe($this->dataStore("myDS")):
Then use the formatted column "formattedDate1" in your export function.
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo