Excel reader sheet variable

Is it possible to get the Excel reader to not only read a path variable but also a sheet name variable?

I have an irritating issue that files we receive from an external source have sometimes been named “Sheet” and sometimes "Sheet " with a trailing space, so I cannot specify the sheet name. I did manage to convert both the path and the sheet name for each file into a variable, but there is no option to use that variable under “sheet selection”. I feel like I am missing something simple! Can anyone assist with this? Thanks!

@JWebb you could extract the name selected in the Excel Reader as a (new) variable to later use in your workflows.

Also there is the “Read Excel Sheet Names”

2 Likes

I used the “Read Excel Sheet Names” to get the sheet name and turn it into a variable. I cannot seem to feed that into the Excel Reader. I have both the path and sheet name set up, but the node just reads it as it would normally (first sheet, specific sheet or by row index).

ExcelSheetFlow

It’s all there and ready, I just can’t make it read that specific variable, even when I set sheet_name to the variable generated from Node 103.

KnimeFlowVariable

@JWebb it might be this problem and you could try to force the use of a sheet name. There also is a ticket in the KNIME system (AP-18133).

2 Likes

Almost there! The difficulty lies in that the different sheets all have different layouts for my data, so it won’t combine them. I cannot find the ticket, but perhaps it will resolve the issue if it picked up! I might just have to discard this piece of work for now…or manually rename all the sheets!

I will keep a copy of that workflow though; that might be useful for other kinds of data. Thanks :slight_smile:

@JWebb you might have to handle sheets with different layouts in a separate way. Most nodes allow for changing specifications; but you will then have to deal with the results.

2 Likes

Can you share your workflow (with dummy data) ?
br

2 Likes

Will it work if the files are saved locally?

If you refer to sharing then yes if you upload the workflow in executed state (not resettet)
br

Hopefully, this works. There is not really a workflow because I can’t get anywhere with it. As you can see, one is called “1 Sheet” and one is called "1 Sheet " with a trailing space. That is what I am trying to get around.
Tab variable.knwf (20.5 KB)

your path variable does not exist for me when I try to run the flow but in general if you feed the path to your excel file it should work
Make sure as already suggested to use the sheet name in the excel reader tab not first sheet with data
br

I am not sure how that works. Whenever I select the sheet name in the Excel reader node, it seems to ignore it and still read the first sheet still.

@JWebb maybe you take another look at this suggestion

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