question

Borja Lorenzo avatar image
0 Likes"
Borja Lorenzo asked Borja Lorenzo commented

Time table import from Excel

Hello

I would like setting a time table from an excel sheet.

These dates don't have a structure or squence, so to load the openning and closing into a schedule, you select the schedule manaully.

Is there an automatic soluction to upload this types of dates without a patron?

How should schedule dates be prepared (type format dates, mesure time between openning and clossing or openning and clossing time) in Excel?


Thanks a lot in advance for your support.

FlexSim 24.1.0
excel importtime tableautomaticallyirregular datesupload dates
· 13
5 |100000

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

Felix Möhlmann avatar image Felix Möhlmann commented ·

Do you have an example of what the imported data looks like. As long as the time format is known, you should be able to generate a DateTime value from just about any date string with the DateTime constructor (see format options in the "toString" method directly above it in the documentation).

If the Excel data is formatted as a date and you import the raw number (number of days since 01. January 1900), you can use the convert() command to transform it into a FlexSim DateTime or Model Time value.

0 Likes 0 ·
Borja Lorenzo avatar image Borja Lorenzo Felix Möhlmann commented ·
0 Likes 0 ·
1720618132788.png (83.0 KiB)
Borja Lorenzo avatar image Borja Lorenzo commented ·

Hello Felix

Thanks for your answer.

I'm checking your propouse and I have several doubts.

How can I know the estructure of comand importTimeTable and search this type of funtions?, I can't find them in the manual

1721129582599.png


I would like adding other doubt about internal estruture of User Command.

What does it mean the param(1) / param (2) / param(3) / param (4) .

I found an entered in this forum but I don't understand it (What means about "param" - FlexSim Community)

1721129904101.png


0 Likes 0 ·
1721129582599.png (14.4 KiB)
1721129904101.png (10.9 KiB)
Felix Möhlmann avatar image Felix Möhlmann Borja Lorenzo commented ·

It's a user command created by me. The example field just shows a possible input to the command, in this case using names from the example model.

"param(N)" is the Nth parameter that is passed into the command. The "Parameters" field defines which type each parameter needs to have, so FlexSim will show an error if too few, too many or the wrong types of data are entered as parameter when calling the function.

See the documention for user commands.

https://docs.flexsim.com/en/24.1/Reference/Tools/UserCommands/UserCommands.html

1 Like 1 ·
Borja Lorenzo avatar image Borja Lorenzo Felix Möhlmann commented ·

Hello
I've just tested the user command but i got an error.
Before that I changed the filepath.
1721197185599.png

The TimeTible was reseted but it shows in the System Console these messages

exception: Error Constructing DateTime: Value not valid date string.

exception: FlexScript exception: MODEL:/Tools/UserCommands/importTimeTable/code at line 39

It pointed to line 39 in the code.

What could it be happenning?


My current version is 24.1.1


Thanks in advance.

0 Likes 0 ·
1721197185599.png (161.6 KiB)
Show more comments

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Felix Möhlmann edited

I built an example that imports data structured like the marked section from your screenshot into a time table.

1720686091365.png

The code assumes that the layout follows exactly what is shown in the screenshot (column 2-6 are default values for work days, following columns store values for days that differ from these). The user command in the attached model first parses through the excel file and stores the default schedule from monday to friday and any special schedules stored in further columns.

It then goes day by day, checks if there is a 'special' entry for that day or otherwise uses the default schedule and adds it for that day. The assumptions is that the time table and model start at midnight. The code currently goes up to the next specified stop time or a maximumm of 60 days.

import-schedule-example-fm.fsm

TestSchedule.xlsx

This model is meant as an example to showcase how to read data from excel, convert date strings into a FlexSim datetime and fill out a time table schedule.

Note: If date time conversion in the command uses the windows default weekday and month names. So as long as the naming in your excel file matches this, the code should also work with other languages.


5 |100000

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