I am using Ver. 6.4.1 and was wondering if someone might be able to provide an example for how to code the collection of
data into an Excel file. When I try to access the zip file for this topic in Knowledge Base, I get a message saying the
file is corrupted.
Thanks.
Willy — 01.07.10
hey, I posted some java code for outputting data to a text file in this thread:
http://www.xjtek.com/support/forum/anylogic6/1034/
I often use this same method to create CSV files, which will open up nicely in Excel.
/w
EY — 02.07.10
Thanks! That was really helpful. I am coming across a problem. I am outputting a dataset (time X product count) into a
CSV file, but both values are being presented in the same cell in Excel. Is this something that can be fixed through
coding or through the application that reads the file?
Willy — 02.07.10
I'm not sure... Can you give an example of what your output looks like if you were to open it with, say, notepad?
/willy
Willy — 02.07.10
Does your file have a .csv extension?
/willy
EY — 02.07.10
It does have a .csv extension. It looks like this in notepad:
Run1
Count0 3
1 3
2 3
3 6
4 18
5 22
6 35
7 84
8 100
I don't have any problems if I copy and paste from text into Excel, but when I open the .csv file in Excel, I will get
something like this (where [] represents a box character that I can't replicate here):
Run1
Count0[]3
1[]3
2[]3
3[]6
4[]18
5[]22
Willy — 02.07.10
Ok... try commas instead of tabs. CSV = Comma Separated Values. When you copy-paste, I guess Excel is picking up the
tabs, but with a .csv extension, it'll definitely be expecting commas.
Also, it looks like you have some malformation at the top. I think your file should look like this:
Run,Count
0,3
1,3
2,3
3,6
4,18
etc...
/w
EY — 02.07.10
Run is the counter for the number of times the simulation has been run, so I expect it to look the way it does. Count
(which is the dataset I am calling on) contains both an x and y value, only one of which I have set up a parameter for
(the time values are being automatically generated as the simulation is executed). Might the dataset itself be the
problem?
Perhaps I will just create txt files to open into Excel.
Willy — 02.07.10
I don't think the dataset is the problem. It's the formatting. What you have is tab-separated and what you need is
comma-separated.
Willy
Pavel — 05.07.10
EY,
Please learn the following articles from the Knowledge Base:
http://www.xjtek.com/support/kb/?s=Excel&category=AnyLogic+6
Here you will find information about how to operate with Excel files from AnyLogic model using Database component. BTW,
new AnyLogic 6.5 includes special "Excel File" object that significantly simplifies this process.
EY — 06.07.10
Willy - I am not sure how to modify the formatting.
Pavel - I have looked at the articles, but cannot run some of the files.
Thanks for all the help.
Amy — 06.07.10
Pavel, I have the same problem. When I download the knowledge base article and files, I get a message that the files are
corrupted. In the past I had a model where I output simulation results to an excel database without any trouble (with a
previous version of AnyLogic). Running the same model using 6.4.1, I get an error message that I never received in the
past. The message says:
java.lang.RuntimeException:Error occured when executing SQL query in modify() method
Caused by: java.sql..SQLException: [Microsoft] [ODBC Excel Driver] the Microsoft Office Access database engine could not
find the object 'Table 1'. Make sure the object exists and that you spell its name and path correctly.
As I said, this same model and excel file has run fine the the past (exact same code, same unmodified model and excel
spreadsheet file)but all of a sudden throws this error.
Any suggestions?
Amy.