question

jacopo-r avatar image
0 Likes"
jacopo-r asked Jason Lightfoot edited

Exporting and importing tables to and from Excel including column headers

Hello,

I need to export and import to and from Excel using the function "excelexporttable" and I don't see any parameter to include the columns header. Is there any way for doing this?

Thanks.

FlexSim 24.0.1
excelexporttableexcelimporttable
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

Can you not use the commands excelmultitableimport() and excelmultitableexport() ?

Then you would be able to specify where the data entries start using starting row and column and just check the option for using column and row headers:

1715955325872.png

In this case the row headers will be from column 2 and the column headers will be from row 6.

If your row headers are in column 1 make sure you enter 0 or 2 for the starting column - a value of 1 forces column one to be read as data, ignoring the checkbox for row data.

From the 24.0 documentation:

"The starting row and starting column fields determine where the Excel Importer will look on the Excel sheet for the data it needs to import. Enter the starting location for your data in these cells not the location of the headers or data distinction information. If you leave the values for these cells at 0, the Excel Importer will automatically adjust where it imports the data from. If you always leave your data at the top left of the worksheet you will never need to enter a value other than 0 in these cells regardless of whether or not you have headers or data distinction information in front of the data."


You can also consider using importtable() and exporttable() which read and write csv files and have the options to specify headers.

5 |100000

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