question

mary avatar image
0 Likes"
mary asked Kavika F commented

Excel export interface

How do i export data from global table to excel automatically. whenever i run the model. Please do help

FlexSim 22.0.0
FlexSim 20.0.10
global tableexcel export
· 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.

Kavika F avatar image Kavika F ♦ commented ·

Hi @mary, was Jeanette F's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Jeanette F avatar image
0 Likes"
Jeanette F answered Jeanette F commented


Hello @mary,

You can export a global table to excel by using this tool in the tool box.

1653599041902.png


You can also use code to export. You can find more details of how to accomplish this in the manual.

" To execute your custom import or export code through a flexscript node or trigger, call the following: "

treenode excelauto = Model.find("Tools/ExcelAuto");
executefsnode(getvarnode(excelauto, "CustomImport"),NULL);
// or
executefsnode(getvarnode(excelauto, "CustomExport"),NULL);

1653599041902.png (39.3 KiB)
· 4
5 |100000

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

mary avatar image mary commented ·
Thank you but I'm looking for automatic export when I restart the model
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ mary commented ·
Then you would put that code in one of the model triggers found in the Toolbox.
0 Likes 0 ·
mary avatar image mary commented ·
can you please let me know what to write in custom code i want to open excel workbook and mention sheet, referring to the particular global table and then exporting to excel.
0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ mary commented ·
{ // ************* PickOption Start ************* //

/**Example Custom Export*/
string directory = modeldir();
if (stringlen(directory) < 3) directory = documentsdir();
string filename = filebrowse("*.xls*","Excel Files",directory); // get the name of the file to open
if (stringlen(filename) == 0) {  // This is true when the user presses Cancel on the file browse window
  return 0;
}

excelopen(filename); // open a link with an Excel workbook

excelsetsheet("Sheet1"); // set the active worksheet - sheet names should contain only alphanumeric characters and underscore (_)

//add your export code here using commands: excelwritenum(), excelwritestr(), excelexporttable()

msg("Excel Export","Export complete",1);

excelclose(1); // save and close the workbook

} // ******* PickOption End ******* //
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.