Create new tabs in an excel sheet based off a column name

I have an excel sheet that has a list of supervisor names on it. The supervisor name repeats for each of their associates. I am trying to separate the supervisors name into different tabs on the same excel sheet. From there, I want to make sure the associate and their entire row is included in the new tab with their supervisors name.

The supervisors have multiple associates. For example:

Name Supervisor
suzy bob
gary bob
mary ann
lisa ann

bob would be a new tab and ann would be a new tab. Bob’s tab would have both suzy and gary and ann’s tab would have both mary and lisa.

Please let me know if I should elaborate further.

Please , elaborate further. I think i am really interested in it

Essentially I run an excel report that has a list of associates and who their supervisor is listed in multiple rows. The supervisors have multiple associates underneath them.

I need to send the spreadsheet to all of the supervisors, but they all need an individual tab on the originally ran sheet. On those individual tabs (which are each individual supervisor) I need to have each associate that reports to them (the row that has both the associate name and the supervisor name).

honestly, not clear

can you give a pictural expalnation for clarity

Hi @aksyracuse , and welcome to the KNIME community,

To summarise my understanding, you have a table containing supervisor and associate data, with multiple rows and each row contains a supervisor along with information about one of their associates. There may be multiple rows per supervisor.

You wish to populate an Excel spreadsheet with the data contained within the table, but with the rows for each supervisor appearing in its own tab.

I hope that is a basic summary of your problem.

To write to a specific tab on an Excel sheet in this way, you will need to ensure that all of the rows for a given supervisor have been grouped together, and then these will be written to the spreadsheet as one table.

A typical way to do this would be to use the Group Loop start node, with the supervisor chosen as the “grouping” column (in the “Include” section on the Group Loop Start node’s config).

In this way, on each iteration of the loop, the rows for a single supervisor will be grouped together and then these can be passed to the Excel Writer. The Excel Writer must be configured to “append”

and on the Flow Variables tab, set the “Sheet name” to use the “supervisor” variable (or whatever the name of the flow variable is that the Group Loop will have created from your “supervisor” column)

Terminate the loop with a Variable Loop end, so it looks like this:

One thing though, if you rerun it and a supervisor is no longer present, this won’t overwrite the excel tab that was previously created for that supervisor. I don’t know if you need it to. This could be handled, by attempting to delete the xlsx file prior to the loop start, or maybe by using a flow variable based on the iteration to control the “overwrite” or “append” setting in the Excel Writer. If you need further assistance with that or anything else isn’t clear, then please ask.

Group Loop and Write Excel Sheet.knwf (15.3 KB)

2 Likes

Hi!

Yes, this helped a lot. I tired it this way, but I was not sure how to load my excel file into the table creator without copying and pasting it over. Is there a way to do this?

Hi @aksyracuse , you don’t load data into a Table Creator other than manually. The Table Creator is just there as an example. Replace the table creator node with an Excel Reader node, to read the data from your existing excel file.
i.e.
image

edit:

Incldentally one option for having the output Excel file “overwritten” on the first iteration, but then subsequently appended to is as attached:

Here a flow variable is created at the beginning of each iteration which sets the a variable containing the excel file overwrite option to either “overwrite” or “append”.

image

This is then configured on the flow variables tab of the Excel Writer:

Group Loop and Write Excel Sheet 2.knwf (18.8 KB)

2 Likes

To then save it into a specific folder on my computer should I used the excel writer again after the variable loop end?

Hi, you would normally configure the Excel Writer within the loop to save to the folder that you wish to save it to. So in my demo I just saved to a file in c:\temp, but you should configure that Excel Writer node to save where you want the final excel to be written to.

Ah ok, that makes sense. It works! Thank you so much for your help!

1 Like

Hi @aksyracuse , I’m glad you got it working.

If you are happy that your question is resolved, can I ask you to hit the :ballot_box_with_check:Solution button at the bottom of the reply that you think best answers your question. (Only one reply can be marked as the solution)

It looks like this: solution button

This then makes it easier for people with a similar question to go straight to the answer, and also shows that a question has been resolved so that people don’t waste time opening it to assist, only to discover that it is already answered. thanks :slight_smile:

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