question

Allen Greenwood avatar image
0 Likes"
Allen Greenwood asked Ben Wilson commented

Automatically export the contents of a Global table at the end of a run.

I need to export data in a Global Table when a model ends. The data needs to overwrite the current contents of the Sheet. I tried using excelexporttable in the OnRunStop Model Trigger but data are appended not overwritten. I also tried deleting Sheet1 then adding Sheet 1 but that didn't work.

FlexSim 21.1.2
flexsim 21.1.2global table excel 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.

1 Answer

Benjamin W2 avatar image
0 Likes"
Benjamin W2 answered Allen Greenwood commented

Hi @Allen Greenwood,

I think the issue you are running into is trying to delete the only sheet in the workbook. Each workbook must contain at least one sheet. In the attached example, I created my own sheet in excel called "MySheet":

Then, I have the following code:

  1. excelopen("ExportTest.xlsx");
  2. exceldeletesheet("MySheet");
  3. excelcreatesheet("MySheet");
  4. excelexporttable("GlobalTable1",1,1,4,1);
  5. excelclose(1);

This will give the appearance of overwriting the data instead of just appending them.

ExportTest.xlsxExcelExportTest.fsm


1620681518218.png (2.3 KiB)
exporttest.xlsx (8.7 KiB)
excelexporttest.fsm (27.4 KiB)
· 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.