question

Flavia P2 avatar image
0 Likes"
Flavia P2 asked hermione12 commented

Export Data to Excel from Flexsim through custom code

Hello everyone,

So i'm trying to export my data from the Statistics Collectors from Flexsim to Excel. I want to do this when the the model stops running so for this I implemented a ModelTrigger to on OnRunStop to execute the node of running a CustomExport.

After this i wrote the code on the Data interface with Excel, like this

So the first part it works, Flexsim runs the custom code after the model stops running but when it starts the export part it does not work and gives all sorts of errors

Opens a window for selecting the xlsx file

Error of closing the excel workbook

Another of that could not open the file

of not set the sheet to Sheet 1, Among others.

Do you have any tips for me on how I can make this work?


FlexSim 19.0.9
flexsim 19.0.9excelexcel exportcostum code
1603297543254.png (347.8 KiB)
1603298226681.png (408.0 KiB)
1603298341415.png (409.4 KiB)
1603298405529.png (503.5 KiB)
1603298475821.png (508.0 KiB)
1603298525442.png (502.4 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Steven Hamoen avatar image
0 Likes"
Steven Hamoen answered hermione12 commented

@Flavia P2 I think that the "\" in the paths should have an escape character so should actually read \\. So your paths should read C:\\User\\Flavia etc.....

That might solve already quite some problems.

· 8
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Flavia P2 avatar image Flavia P2 commented ·

I will try that thank you so much

0 Likes 0 ·
Flavia P2 avatar image Flavia P2 commented ·

Just another question @steven.hamoen, do you know to access the Statistics Collectors Table so I can export it?

I have tried this code but no luck,

excelexporttable("Tools/Statistics Collectors/StatisticsCollector1>stats/data",1,1,3,3);

Do you have any ideas?

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen Flavia P2 commented ·

@Flavia P2 If you read the helpfile or command help for the excelexporttable() function you will read: " The table may be referenced by the name of a GlobalTable or by using a treenode reference to a table node. " Considering you are not dealing with a GlobalTable you have to enter a node reference. You just entered a simple string with no meaning. if you change it into:


excelexporttable( node("Tools/Statistics Collectors/StatisticsCollector1>stats/data" ),1,1,3,3)

it should work better.

1 Like 1 ·
hermione12 avatar image hermione12 Steven Hamoen commented ·

Hello @Steven Hamoen , how to reference global table for this function excelexporttable() ? What is the command to reference global table?

0 Likes 0 ·
Show more comments