# Can I loop through tabs in an Excel Spreadsheet?

**URL:** <https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679>\
**Category:** KNIME Analytics Platform\
**Created:** [May 13, 2013, 9:00pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679 "2013-05-13T21:00:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jontimko](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/dec6dc/32.png) [@jontimko](https://forum.knime.com/u/jontimko)\
**Post date:** [May 13, 2013, 9:00pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/1 "2013-05-13T21:00:38Z")

</div>

Is there a way to loop through tabs of an Excel spreadsheet in a workflow? I know the Excel reader allows you to choose the sheet you want to extract data from. But can the sheet name be used as a variable in a workflow to process each sheet? If so, how would it be defined?

Thanks

Jon Timko

---

<div class="post-metadata">

**Author:** ![gabriel](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gabriel/32/61386_2.png) [@gabriel](https://forum.knime.com/u/gabriel)\
**Post date:** [May 14, 2013, 8:33am UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/2 "2013-05-14T08:33:55Z")

</div>

In the current KNIME version you need to know the sheet names before processing them. A simple workflow, would have a Table Creater (with the sheet names), A TableRow to Variable Loop Start node (provides each sheet as a variable), the XLS Reader (connected with the variable port from the loop start), and a Loop End which collects the results. The XLS Reader need to have the variable (which is the original column name) assigned in the dialog tab "Flow Variables" as SHEET\_NAME. In next release, we will have a XLS Sheet Name Reader allowing to set up more dynamic workflows.

---

<div class="post-metadata">

**Author:** ![glenerik](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@glenerik](https://forum.knime.com/u/glenerik)\
**Post date:** [August 2, 2016, 6:17pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/3 "2016-08-02T18:17:52Z")

</div>

This doesn't work. XLS reader node set with SHEET\_NAME flow variable "Sheet" from XLS Sheet Name reader but xls reader settings does not use flow variable to define which sheet to read. Hence, it loops through and keeps reading the first sheet on every loop.

---

<div class="post-metadata">

**Author:** ![Iris](https://forum-cdn.knime.com/user_avatar/forum.knime.com/iris/32/14_2.png) [@Iris](https://forum.knime.com/u/Iris)\
**Post date:** [August 2, 2016, 7:13pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/4 "2016-08-02T19:13:55Z")

</div>

Sure it does :-)

&nbsp;

you first need a read xls sheet names, than a table row to variable than the xls reader and the last node in row is the loop end.

In the xls reader go to the flow variables tab and select the sheetname flovariable for the flowvariable SHEET\_NAME

Cheers, Iris

---

<div class="post-metadata">

**Author:** ![dvkumaraws2019](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/278dde/32.png) [@dvkumaraws2019](https://forum.knime.com/u/dvkumaraws2019)\
**Post date:** [February 16, 2022, 9:34pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/5 "2022-02-16T21:34:10Z")

</div>

I tried the Excel Reader, and the Sheet\_Name variable is not getting parsed. For the total number of excel tabs, only the first sheet is read. so if there are 10 tabs, only the first sheet is read 10 times and not the rest of the sheets at all.

I think this is a major bug in KNIME.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [February 16, 2022, 10:02pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/6 "2022-02-16T22:02:16Z")

</div>

@dvkumaraws2019 you could take a look at this entry (AP-18133):

> [@\[bug or no bug ?\] Excel Reader preconfigured work sheet selection options](https://forum.knime.com/t/bug-or-no-bug-excel-reader-preconfigured-work-sheet-selection-options/38226/7):
>
> @Geo what you could do is force the use of sheet\_selection = “NAME” thru a Flow Variable in case of doubt. Maybe not the most elegant way but shout provide an additional layer of security. And indeed under certain circumstances it seems to revert to the default value. Not able to reproduce it yet in a constant way. But might be worth looking into, @laaaarsi.

> **[Loop thru same Excel sheet names from various sources and collect them back –...](https://hub.knime.com/mlauber71/spaces/Public/forum/kn_forum_27953_loop_multiple_excel_files~zDsvqAhP4BgUr37R/current-state)**
>
> Loop thru same Excel sheet names from various sources and collect them back

---

<div class="post-metadata">

**Author:** ![ScottF](https://forum-cdn.knime.com/user_avatar/forum.knime.com/scottf/32/61316_2.png) [@ScottF](https://forum.knime.com/u/ScottF)\
**Post date:** [February 17, 2022, 4:49pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/7 "2022-02-17T16:49:00Z")

</div>

Hi @dvkumaraws2019 -

This thread is several years old, and things have changed a lot with the Excel Reader since it was originally posted. What you’re describing sounds like a misapplication of a flow variable, but it’s hard to be certain based on the information provided.

If you are still having trouble, could you post your existing workflow in a new thread, so we can try to diagnose and troubleshoot? I will close this thread to keep the forum tidy. Thanks!

---

<div class="post-metadata">

**Author:** ![ScottF](https://forum-cdn.knime.com/user_avatar/forum.knime.com/scottf/32/61316_2.png) [@ScottF](https://forum.knime.com/u/ScottF)\
**Post date:** [February 17, 2022, 4:49pm UTC](https://forum.knime.com/t/can-i-loop-through-tabs-in-an-excel-spreadsheet/2679/8 "2022-02-17T16:49:04Z")

</div>


