question

Thomas JR avatar image
0 Likes"
Thomas JR asked Thomas JR commented

Change target .xlsx file in Excel interface through custom code

Is it possible to change the target file in “Excel Workbook” through custom code?

I need to change it for all of my defined exports.

FlexSim 21.0.0
flexsim 21.0.0excel interface
· 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.

martin.j avatar image martin.j commented ·

Hi Thomas,

If all of your exports are pointed at the same file you could also simply leave Excel Workbook value blank for all but the first export line. Then it will automatically use the value from the first line. Then if you ever need to change it again, you can simply change the path in the very first export to change them all.

You can use Lars's method to clear them all and then manually set the first export. - in the above case ExportLine1.

Table exports = getvarnode(model.find("Tools/ExcelAuto"), "exporttable");
for (int row = 1; row <= exports.numRows; row++)
    exports[row][1] = ""; //"C:\\MyNewFileLocation\\File.xlsx";
0 Likes 0 ·
fileexport.png (7.0 KiB)

1 Answer

·
Lars Christian J2 avatar image
1 Like"
Lars Christian J2 answered Thomas JR commented

You can use

getvarnode(Model.find("Tools/ExcelAuto"), "exporttable").as(Table)[1][1]

to change the export target .xlsx file for the first export. Increment the table row for each export file.


I.e.

getvarnode(Model.find("Tools/ExcelAuto"), "exporttable").as(Table)[1][1] = "C:\\MyNewFileLocation\\File.xlsx";

Note that you need to use \\ in the file path, as a single \ will be deleted by the parser.

· 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.

Thomas JR avatar image Thomas JR commented ·

Thank for the solutions. However I have found a workaround because the main original intention was somewhat ill-conditioned.

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.