I am having a difficult time getting data from an Excel file I've created. My ultimate goal is to use the Excel file to
populate agent parameters that will be unique to the replicated agents.
The error I am getting is associated with this piece of code run on startup:
ResultSet rs=database.getResultSet("SELECT * FROM [CityData]");
the database is linked via an explicit path to an excel file CityData.xls
Any thoughts?
thanks in advance
Pavel — 21.08.08
Hi Robby,
You should type the name of the table in the SQL query, not the file's name. Please open your Excel file and select all
cells that contains the required data and type the table's name in the left upper corner where cell's name is displayed.
For more information please look at the article in the Knlowdge base:
http://www.xjtek.com/support/kb/?id=82
"DataForPlot" in this example it is the name of the table in the Excel spreadsheet.
Robby — 30.08.08
Thanks, that was it, I hadn't successfully created the table in Excel.
One more question: as I mention my goal is to take values from the Excel table to populate several parameters for
replicated agents in my model (where each instance of a replicated agent would correspond to a single row in the
table).
I am creating the ResultSet via the database as part of my Main object startup code. Can I access this directly from
the embedded agent object or do I need to do something else to populate the agent parameters from this ResultSet?
Thanks again!
Pavel — 17.09.08
Robby,
This ResultSet is created in the "Startup code", so it is available only from it. You may create auxiliary
variables in "Main" and assign values from the Excel file to them, also it can be a collection variables. Thus
they can be used to define agent's parameters when the model starts. This approach is similar to that is described in
the Knowledge base article mentioned in my previous post.