KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

Call to undefined method report::exportToCSV() #1297

Open ugakr opened this topic on on Feb 12 - 6 comments

ugakr commented on Feb 12

I'm trying to export my report to a CSV file with no extra options besides BOM being false. I've also made sure to add the use line in my report.php. Heres the error:

Call to undefined method report::exportToCSV() in C:\Users\name\Documents\KoolReportsProject\site\table.php

This is how I create and run the report:

      require_once "report.php";
      $report = new report;
      $report->run()->exportToCSV('report', array(
        "BOM"=>false,
      ))->toBrowser("report.csv");

..and of course I have this

    class report extends \koolreport\KoolReport{
      use \koolreport\excel\CSVExportable;

It DOES download a csv file, but it's completely empty. Any help would be much appreciated.

ugakr commented on Feb 13

For whatever reason I don't get an error anymore; my site just gives me the download to an empty csv file, while my render shows what it should actually look like.

KoolReport commented on Feb 13

..

David Winterburn commented on Feb 13

Hi,

The first parameter of exportToCSV should be a datastore name in your report like this:

require_once "report.php";
      $report = new report;
      $report->run()->exportToCSV('myDatastore', array(
        "BOM"=>false, 
      ))->toBrowser("report.csv")
ugakr commented on Feb 14

I should have mentioned this before (apologies) but my current code does have my datastore name in place of "report". Also, I now get a separate error

Could not found excel export template file

which I think happened when I changed my exportable to the BigSpreadsheetExportable (which I read still includes the CSV export function). Any ideas? I've tried most variations of importing the exportables and different export functions but none seem to work. It seems like (from the exception handler) that it checks for a .view.php file for the 1st argument, which afaik won't exist for a datastore. It will however, exist for a report. Checking the exception when i do a datastore as the argument throws saying "datastorename.view.php" doesn't exist. Looking past this and creating a datastore.view.php file also lets me download it, but it's still empty.

David Winterburn commented on Feb 17

Hi,

With BigSpreadsheetExportable, please call exportToCSV like following:

$report->exportToCSV(array(
    'dataStores' => array(
        'orders' => array(),
    ),
    'BOM' => false, //default = false
    'fieldDelimiter' => ';', //default = ","
    'useLocalTempFolder' => true,//default = false
))
->toBrowser("MyReport.csv");

Let us know if it works for you. Thanks!

ugakr commented on Feb 17

It seems I get < or <h and nothing else in the file (which is better than nothing); do I put in dataStores literally and the name of my datastore in place of orders? I've tried some different ways and names but none of them seem to get the real csv file. I've tried my actual datastore name in place of dataStores, i've tried it in place of orders, I've put my report name in those two as well, etc. Just a little confusion on my end. Here's what I have now:

'dataStores' => array(
        'agent_data' => array(),
    ),
    'BOM' => false, //default = false
    'fieldDelimiter' => ';', //default = ","
    'useLocalTempFolder' => true,//default = false
))

where agent_data is my $this->dataStore value.

Appreciate the help!

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

Export