j08j avatar image
j08j asked j08j commented

Questions about using flexscript to import excel

I want to use flexscript to import the Data.xlsx file into GlobalTable1 according to the settings in the figure below, but it has not been successful.


Where is the problem?

Thanks for the help.

FlexSim 24.0.2
flexscriptcodeexcel import
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

Felix Möhlmann avatar image
Felix Möhlmann answered j08j commented

In the command "excelimporttable()" you have to actually specify the start row/column and number of rows/columns to import. The target table also must already have these dimensions as it will not automaically resize to fit the data and the data types of its columns must also match the data in the excel file.

You can also run the import defined in the interface with "excelmultitableimport()".

· 5
5 |100000

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

j08j avatar image j08j commented ·

There are my excel sheets:截圖-2024-06-11-下午44510.png

截圖-2024-06-11-下午44520.pngI made the following modifications:截圖-2024-06-11-下午44618.png

but it shows error:截圖-2024-06-11-下午45159.png

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann j08j commented ·
Are you trying to read a value from the tables after importing? Because you are not setting their size. Newly created tables will have one row and one column. As I mentioned already, the excelimporttable() command will not adjust their size by itself. Use "Table().setSize()" before you import.
0 Likes 0 ·
j08j avatar image j08j Felix Möhlmann commented ·

Thanks, it works successfully. But I have a question. If the data in Sheet1 is a different array size every time I inport it, what should I do? Is there any other way besides directly setting a super large size?

0 Likes 0 ·
Show more comments