question

Craig DIckson avatar image
1 Like"
Craig DIckson asked Logan Gold edited

How can I use a relative path for Excel output?

I am using Excel for both input and output from my model (which is completely process flow).

When I use MTEI to read in my input table, I am able to use a relative path, e.g. " ..\Data\Inputs.xlsx". But for MTEE and custom output, it seems to insist on the full path. Am I missing something? Thx

FlexSim 16.0.1
excel
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

Adrian Haws avatar image
5 Likes"
Adrian Haws answered Logan Gold edited

Relative paths do work for MTEE, as long as the exporter is set up correctly. However, for custom export when you call

excelopen() 

it needs the absolute path. If you want to use a relative path you can enter

excelopen(concat(modeldir(), “..\\Data\\Inputs.xlsx”))

Notice that there are two backslashes before and after “Data”.

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

Craig DIckson avatar image Craig DIckson commented ·

Taanks,

I'm not sure what I did before, but I did get the MTEE to use the relative path now. Is there a command I can call from code to run the MTEE at the end of run?

But I still am having problems with the custom export. When I run it I get a form that says:

"Could not open file c:\Projects\QVC\Solution\Model\..\Data\Outputs.xlsx". Seems like I may need another step to handle backing up a level? Note that the model is in:

c:\Projects\QVC\Solution\Model\*.fsm

while the Excel files are in

c:\Projects\QVC\Solution\Data\*.xlsx

Thanks,

Craig

0 Likes 0 ·
Adrian Haws avatar image Adrian Haws Craig DIckson commented ·

@Craig DIckson we've tested this in FlexSim 2016 with the ..\\ notation and it worked. When you export make sure it's to a file that has already been created, otherwise it won't work. Also, make sure to not have the spreadsheet open when you try to export to it.

0 Likes 0 ·
Craig DIckson avatar image Craig DIckson Adrian Haws commented ·

Adrian,

Can you look at this and see what's wrong (code below). It still doesn't seem to be working for me? I confirmed that the file and the sheet are both there.

excelopen(concat(modeldir(), "..\\Data\\Outputs.xlsx"));

// Set sheet to write to excelsetsheet("Orders");

// Write results

// Number of orders created excelwritenum(8,2,vOrderNumber);

excelexporttable("Output_Orders_OrderProfile",8,3,1,10);

excelclose(1);

0 Likes 0 ·
Show more comments