Ordering of excel worksheets

Hi,
Is there any possibility that I can arrange the excel worksheets in a sequence that I wish to have it in. Is there any node for the same?
Any help would be appreciated!

Thank you!

Hi @Saishiyam I don’t think there is a node that does this. However, you can do this with a few nodes.

The important thing is to write to the sheets in the Excel file in the order that you want them to be. So that’s what you have to do when you are writing.

If you have existing files that you want to re-arrange, you can:
1- Use Read Excel Sheet Names
2- Sort the names
3- Loop through the sorted names
4- Inside the loop, read the content of the sheet
5- Write to new sheet in new file

2 Likes

Hi @bruno29a, thanks for the reply. But the pivot gets generated at the last node and that’s what they need it first. Will connecting flow variables be of any help in order of execution of the nodes?

And regarding the existing file reordering method, I fear it might create the heap error issue as we are writing it already in xls format.

@Saishiyam you could use OpenPyxl to move a sheet to a new position. I adapted an older workflow and put the code into a Component. With the new KNIME 4.6 Python integration the usage should become much easier:

You could also check the underlying index with the help of Python:

image

2 Likes

Hi @Saishiyam ,

Well, I don’t know what’s your use case :slight_smile:

What I proposed is applicable for a specific use case.

Definitely yes, connecting nodes with flow variable ports will help with the order of execution of the nodes.

So, if your use case has different nodes writing to different sheet, you can control their order of execution by linking the nodes via the flow variable ports.

For example:
image

Node 5 will run only after Node 4 has completed, and
Node 4 will run only after Node 3 has completed, and
Node 4 will run only after Node 2 has completed

meaning the order of execution of the Excel Writer nodes will be:
Node 2, Node 3, Node 4, Node 5

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.