# Excel Table Writer Node & Openpyxl

**URL:** <https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036>\
**Category:** KNIME Extensions\
**Tags:** python, other-knime-extensions\
**Created:** [August 25, 2023, 9:46pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036 "2023-08-25T21:46:09Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![qdmt](https://forum-cdn.knime.com/user_avatar/forum.knime.com/qdmt/32/51181_2.png) [@qdmt](https://forum.knime.com/u/qdmt)\
**Post date:** [August 25, 2023, 9:46pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/1 "2023-08-25T21:46:09Z")

</div>

I am trying to use the **[Excel Table Writer](https://hub.knime.com/tommy/spaces/Public/latest/Excel%20Table%20Writer~EnxXLRACyo7A_tGI)** node, which I understand requires the openpyxl module.

In KNIME, I have confirmed selection of my environment “env”.

In Anaconda Shell Prompt, I have confirmed that “openpyxl” is correctly installed in that same environment.

Yet, when I run the node, the node errors out and says

```auto
ModuleNotFoundError: No module named 'openpyxl'

```

I have an excel model that uses INDEX/MATCH & XLOOKUP extensively to reference a sheet that contains the data that KNIME writes into. This data is not fixed and expected to grow.

If I don’t use the Excel Table Writer node, I am constrained to using entire A:A column references (as opposed to strictly the range or table object I need).

Excel Table Writer node seems like it would be a great solution otherwise.

---

<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:** [August 29, 2023, 8:16pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/2 "2023-08-29T20:16:23Z")

</div>

Hi @qdmt -

To me this seems like some sort of misconfiguration in the KNIME preferences about exactly which environment is being used. Are you certain you’re pointing to the Conda envrionment that you’re updating via the shell prompt, as opposed to KNIME’s bundled one?

![2023-08-29 15_13_39](https://forum-cdn.knime.com/uploads/default/original/3X/f/6/f64241465e86e3d7e8360a760e1b8ba9df1f65dc.png)

Sorry if this question seems silly, just trying to narrow down what’s happening. I’ll also tag @tommy since it’s his component we’re discussing.

---

<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:** [August 29, 2023, 8:48pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/3 "2023-08-29T20:48:59Z")

</div>

@qdmt [openpyxl](https://hub.knime.com/search?q=Openpyxl&type=Workflow&sort=best) should be part of the [bundled Python version in KNIME](https://www.knime.com/blog/how-to-setup-the-python-extension).

---

<div class="post-metadata">

**Author:** ![qdmt](https://forum-cdn.knime.com/user_avatar/forum.knime.com/qdmt/32/51181_2.png) [@qdmt](https://forum.knime.com/u/qdmt)\
**Post date:** [August 29, 2023, 10:07pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/4 "2023-08-29T22:07:46Z")

</div>

@ScottF @mlauber71

I can confirm I’m pointing to Conda under KNIME \> Python:  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/2/e2e1301f949a144bfbf069421df3df4f063f8049.png)

Under KNIME \> Python Legacy, I can also confirm I’m using the matching environment for Python 3:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/b/6b77a06c51e817805044afdbbd7429c6dbb9d442.png)

I can further confirm that openpyxl is visible to the Python Script node using the following script:

```auto
import sys
sys.path.append("path_to_conda_environment/lib/pythonX.X/site-packages")
import openpyxl
print(openpyxl. __version__ )

```

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/d/6/d649e706a680c8be8bf63ecb3149ac3fd66163cc.png)

---

<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:** [August 29, 2023, 10:36pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/5 "2023-08-29T22:36:54Z")

</div>

Two things to try:

1. Can you verify that openpyxl is present when imported in the [Python Script (legacy)](https://kni.me/n/6L0w9_dCmFzbn-rx) node, as opposed to the standard Python Script node shown in your screenshot?

2. Since as @mlauber71 pointed out, openpxyl is present in the bundled Python environment, what happens when you switch over to that in the KNIME settings?

---

<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:** [August 30, 2023, 3:14am UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/6 "2023-08-30T03:14:01Z")

</div>

@qdmt you might have to see how Python is configured in the component. You could also check this example that should just use the bundled version:

> [@Write KNIME table to Excel as table (proposal)](https://forum.knime.com/t/write-knime-table-to-excel-as-table-proposal/14044/10):
>
> OK I think now I get what you want. Yes it is possible to first save a table as a ‘pure’ excel file and then define a range as a table object “All” which you can later use to refer to it. In my example the no of lines that the object would have is assigned dynamically while the columns are fixed but one might also be able to change that to a dynamic setting. After the ‘raw’ KNIME export: After openpyxl got to work: (cf. [https://openpyxl.readthedocs.io/en/stable/…](https://openpyxl.readthedocs.io/en/stable/worksheet_tables.html)

> **[KNIME and Python's openpyxl to define and name a Data area in Excel (using...](https://hub.knime.com/mlauber71/spaces/Public/kn_example_python_excel_table_object_filter~AmjUaMkYS9v1Cosj/current-state)**
>
> KNIME and Python's openpyxl to define and name a Data area in Excel (using the bundled Python version) https://forum.knime.com/t/write-knime-table-to-excel-as-…

---

<div class="post-metadata">

**Author:** ![tommy](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@tommy](https://forum.knime.com/u/tommy)\
**Post date:** [August 30, 2023, 11:10am UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/7 "2023-08-30T11:10:21Z")

</div>

hi @qdmt , @ScottF

I just checked the functionality of my component after establishing a new Python3 environment via KNIME preferences.

It generated the same error as stated in the original post here.  
Thus, I installed the package via “pip install openpyxl” in a conda prompt.

That did the trick.

Hope that helps, greets  
tommy

---

<div class="post-metadata">

**Author:** ![qdmt](https://forum-cdn.knime.com/user_avatar/forum.knime.com/qdmt/32/51181_2.png) [@qdmt](https://forum.knime.com/u/qdmt)\
**Post date:** [August 30, 2023, 12:43pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/8 "2023-08-30T12:43:20Z")

</div>

> [@ScottF](#):
>
> 1. Can you verify that openpyxl is present when imported in the [Python Script (legacy)](https://kni.me/n/6L0w9_dCmFzbn-rx) node, as opposed to the standard Python Script node shown in your screenshot?
> 2. Since as @mlauber71 pointed out, openpxyl is present in the bundled Python environment, what happens when you switch over to that in the KNIME settings?

With 1, yes, can confirm it is present with 3.1.2.  
With 2., I had the same error either way.

@mlauber71  
Interesting example - I was using the Excel Table Writer node, which uses openpyxl. That might be the way to go so I can impart a bit more control on the config.

@tommy pip install openpyxl was one of the first things I did.

I might throw in the towel on the Excel Table Writer node for now. My dataset seems to have outgrown the node’s ability to efficiently process the info. At only ~170k rows, it takes a bit too much time (10min+) to write the table, only to run into the openpyxl error.

I’ll revisit the issue later, but perhaps will help point others to @mlauber71’s reference example in the meantime (unless others disagree). Cheers

---

<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:** [August 30, 2023, 1:46pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/9 "2023-08-30T13:46:35Z")

</div>

@tommy from what I see your component uses a legacy Python node and also it does not seem to have dynamic settings of the rows and columns (if I am not mistaken). Maybe you can update the component and use the bundled Python environment and also create a dynamic setting for the rows and columns.

---

<div class="post-metadata">

**Author:** ![tommy](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@tommy](https://forum.knime.com/u/tommy)\
**Post date:** [August 30, 2023, 9:32pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/10 "2023-08-30T21:32:42Z")

</div>

hi @mlauber71

thanks for providing the hints.  
I have to admit that I left this component untouched for some time.  
Now, it has been updated and I have replaced the legacy Python node by a Python script and updated the code.  
The number of rows and columns is calculated based on the input table, so the whole table get’s converted. In case there are some user requirements to filter some information, the user might use a row/column filter node in advance.  
What do you mean by “dynamic setting”?

My test with the new setup was successful. Hopefully, it’s stable.

thanks, tommy

---

<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:** [August 30, 2023, 10:20pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/11 "2023-08-30T22:20:57Z")

</div>

@qdmt does the updated component work for you? If so we could mark tommy’s latest post as the solution.

---

<div class="post-metadata">

**Author:** ![qdmt](https://forum-cdn.knime.com/user_avatar/forum.knime.com/qdmt/32/51181_2.png) [@qdmt](https://forum.knime.com/u/qdmt)\
**Post date:** [September 1, 2023, 1:38am UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/12 "2023-09-01T01:38:36Z")

</div>

Will check report/update back asap

---

<div class="post-metadata">

**Author:** ![qdmt](https://forum-cdn.knime.com/user_avatar/forum.knime.com/qdmt/32/51181_2.png) [@qdmt](https://forum.knime.com/u/qdmt)\
**Post date:** [September 3, 2023, 4:39pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/13 "2023-09-03T16:39:01Z")

</div>

@ScottF @tommy @mlauber71

Reporting back - the update worked. Thanks @tommy for the update.  
It also works despite running 4.7.

Cheers

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [September 10, 2023, 4:39pm UTC](https://forum.knime.com/t/excel-table-writer-node-openpyxl/72036/14 "2023-09-10T16:39:26Z")

</div>

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