How to load only the last sheet in a spreadsheet

Another issue I'm facing is importing a file with multiple sheets. Basically, a new sheet is added to the same Excel file every month. This sheet is added in the last position. And the name of this sheet changes every month (i.e. Nov 2023, Dec 2023, Jan 2024, and so on). So how can I instruct EasyMorph to import this last sheet every time?

The solution in a nutshell:

  1. Use the "Excel command" action to obtain a list of sheets in the spreadsheet.
  2. Filter the list to keep only the last sheet in it (e.g. using the "Trim table" action).
  3. Use the "Call" action to call another module and pass the sheet name to that module as a parameter.
  4. In the other module, use the "Import from Excel" action in the "Worksheet defined by parameter" mode.

Tutorial articles required for understanding the workflow:

Below is a sample project that loads only the last sheet:
load-last-sheet.morph (4.2 KB)
sample.xlsx (10.0 KB)

Thanks, Dmitry. Two questions:

  1. How to make this work when you don't know the Excel file's name in advance (in my case, I have downloaded the file using the 'List of files' action)?

  2. As you can see in the screenshot below, the Excel command has listed the sheets in a different order than that on the Excel file (the bottom sheet should be "Noviembre 2023"). Why is this and how to fix it?

In many actions, including "Excel command" and "Call" you can use a first column value in action settings.


To pass the file name into the called module, create a parameter for the file name in the called module and assign it in the "Call" action in the main module.

Oh, I didn't realize the action lists sheets alphabetically rather than in the order they appear in the workbook. Let me talk to our developers about what we can do in this case. Perhaps, we will need to add a column with the sheet position in the workbook.