question

hermione12 avatar image
0 Likes"
hermione12 asked hermione12 commented

Custom Excel Export query

I have a model, I want to custom export excel data from the Custom Export tab. I do not want any directory or path to be specified. I just want an empty excel to open and then the data should be exported on Model Runstop. How to do it?

export-excel.fsm

FlexSim 20.0.10
excelexportcustomexport
export-excel.fsm (40.9 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

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered hermione12 commented

When FlexSim dumps data to Excel, you can't see or interact with that instance of Excel. So in order to keep the data, you must save it to a file. Then you can launch a normal instance of Excel, to view that file.

Here is a script that you might find helpful:

string tempPath = modeldir() + "test" + realtime(1).as(int) + ".xlsx";

// create a temp file
excellaunch();
excelcreateworkbook();
excelsave(tempPath);
excelclose(0);

// Set the excel exporter to use the temp file
treenode exporter = Model.find("Tools/ExcelAuto");
Table exportTable = getvarnode(exporter, "exporttable");
exportTable[1][1] = tempPath;

// Do the export
excelmultitableexport();

// Open the new file
rundocument("open", tempPath);

This script assumes that

  • You have saved the model at some point
  • The Excel tool is configured to export
    • All exports except the first are set to use the same workbook as the previous
    • The first export is left on NEW. The script overwrites the first value, so it doesn't matter; NEW is just a nice starting point.

The script generates a unique-ish file name by using the current time. It then makes the file and saves it. Then it sets the Excel tool to use the new file for export. It does the export, and then opens the new file for you to see.

This will create a new file every time you run. If you like the file, I'd suggest saving it with a new name, and periodically deleting the files that you didn't keep.

· 1
5 |100000

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

Thank you so much @Jordan Johnson , it is working now.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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