KoolReport's Forum

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

Using an xls as a datasource #2857

Open Richb201 opened this topic on on Oct 29, 2022 - 1 comments

Richb201 commented on Oct 29, 2022

My user has an xls that has some confidential data. I want to use it in Koolreport as a datasource.I am using codeigniter so I have set up a form where the user picks the xls file from their hard drive, and then I transfer it up to my server using

  $data = array('upload_data' => $this->upload->data());   <<this uploads the file to the server

  $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xls");
  $reader->setReadDataOnly(true);
  $file = $data["upload_data"]["full_path"];
  $spreadsheet = $reader->load($file);

So far so good. My site uses https and I use AWS RDS. So once I get the table up to my server, the environment is pretty secure, I think.

The next stage is do some processing on it and then to write it out row by row to a mysql table. So I need to be able to go through the datastore, row by row, and insert into a mysql table. Is there any example of doing this?

Sebastian Morales commented on Oct 31, 2022

I would suggest writing an insertToMySQL($row) function and looping through your excel rows one by one and call the function insertToMySQL for each row. That's the general idea, if you have any question about details pls let us know. Rgds,

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

None