Search code examples
anylogic

"Error: java.sql.SQLException" When exporting database table to excel AnyLogic


I am trying to export a table from AnyLogic's database to an excel file in a parameters variation using this code:

Database myFile = new Database(this, "A DB from Excel", "DataBaseExport.xlsx");
ModelDatabase modelDB = getEngine().getModelDatabase();
modelDB.exportToExternalDB("flowchart_stats_time_in_state_log", myFile.getConnection(), "Sheet 1", true, true);

I am then given this error enter image description here

With this after

enter image description here


Solution

  • It turns out that the name of the excel sheet "sheet1" is the culprit. Upon removing the "1" and creating matching column names in the excel file, the data is able to be exported.