Technote Details :: My CSV Export page shows an error message
Issue
When trying to export data from a NeXTensio list, I get an error message saying:
CSV_Export Error.
Passed argument is not a valid recordset.
Reason
This happens because the code for the CSV export transaction is executed before the actual recordset creation.
Solution
To resolve this issue, you must move the code block that executes the CSV export after the lines that create the recordset. The code that performs the CSV export is enclosed between comments, like shown below:
// Begin CSVExport
$csv = new CSV_Export($rscompany_com1);
$csv->addColumn("name_com", "STRING_TYPE", "Name");
$csv->addColumn("address_com", "STRING_TYPE", "Address");
$csv->setFilename("rscompany_com1.csv");
$csv->setHeaders(true);
$csv->setDelimiter(",");
$csv->setEnclosure("\"");
$csv->Execute("POST", "export");
// End CSVExport
Move the entire code block after the recordset definition. For the example above, the recordset definition starts like this:
//NeXTenesio3 Special List Recordset
$maxRows_rscompany_com1 = $_SESSION['max_rows_nav_listcompany_com5'];