KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Use a CSV file as my source dynamically #868

Open Giulia Fois opened this topic on on May 14, 2019 - 2 comments

Giulia Fois commented on May 14, 2019

Hello, I'm trying to generate a report based on data that are stored in a CSV file. However, each time I generate the report the CSV file varies (I need to create different reports for different clients). Is there a way to pass my .csv filename as a parameter to my report class? I tried using the params array, but I need the parameter to be accessible in the settings() function in order to successfully create my CSVDataSource. Thank you so much.

David Winterburn commented on May 14, 2019

Hi Giulia,

Please try this code in the report setup function:

$dsSetting = array(
	'filePath' => $this->params["myCsvFilePath"],
	'fieldSeparator' => ';',
);
$src = new \koolreport\datasources\CSVDataSource($dsSetting, $this);
$src->pipe(
    ...
);
...

Let us know this works for you or not. Thanks!

Giulia Fois commented on May 15, 2019

Thank you so much, it worked perfectly!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

None