# Export data to excel as table

**URL:** <https://forum.knime.com/t/export-data-to-excel-as-table/18796>\
**Category:** KNIME Analytics Platform\
**Created:** [October 15, 2019, 7:14am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796 "2019-10-15T07:14:47Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![JinnyLe](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@JinnyLe](https://forum.knime.com/u/JinnyLe)\
**Post date:** [October 15, 2019, 7:14am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/1 "2019-10-15T07:14:47Z")

</div>

Hi all,  
I would want to seek guidance on how to export data to excel file and the data is saved as Excel table.

As i’m going to do a loop to create multiple files, i would like to save data as table in KNIME instead of opening it and convert manually in Excel.

Thank you!

![image](https://forum-cdn.knime.com/uploads/default/original/2X/3/33e81a480ef91cd133f1518c9ea1f287e9c0c247.png)

---

<div class="post-metadata">

**Author:** ![ipazin](https://forum-cdn.knime.com/user_avatar/forum.knime.com/ipazin/32/806_2.png) [@ipazin](https://forum.knime.com/u/ipazin)\
**Post date:** [October 15, 2019, 8:36am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/2 "2019-10-15T08:36:48Z")

</div>

Hi there @JinnyLe,

I’m not sure I understand and to avoid guessing can you explain what are you trying to do one more time?

Br,  
Ivan

---

<div class="post-metadata">

**Author:** ![JinnyLe](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@JinnyLe](https://forum.knime.com/u/JinnyLe)\
**Post date:** [October 15, 2019, 9:19am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/3 "2019-10-15T09:19:15Z")

</div>

hi Ivan,

After i use the Excel reader note at the end of my flow, i manage to export the data into Excel. However, the data is not in “table form” in excel. Usually if i need to convert the data into table form, i need to go open the Excel file -\> choose the data range -\> Ctrl + T to create Table.

So i’m asking if there is a way to convert data range into Table form in KNIME itself. Not sure if i’m clear enough? Thanks so much!

---

<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:** [October 15, 2019, 9:31am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/4 "2019-10-15T09:31:45Z")

</div>

Well yes that is actually possible but only with the help of Python package [OpenpyXL](https://openpyxl.readthedocs.io/en/stable/worksheet_tables.html). You can find an example here:

> [@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)

---

<div class="post-metadata">

**Author:** ![JinnyLe](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@JinnyLe](https://forum.knime.com/u/JinnyLe)\
**Post date:** [October 15, 2019, 10:53am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/5 "2019-10-15T10:53:07Z")

</div>

hi Ivan,  
This is great! I tried to run the above flow and this is the message i receive at the Python nodes. Not sure if you know the reason?

“ERROR Python Script (1⇒1) 8:8 Execute failed: No module named ‘openpyxl’  
Traceback (most recent call last):  
File “”, line 5, in   
ModuleNotFoundError: No module named ‘openpyxl’”

 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/4/4bc00946b813fcf328d3acd2bad2bbae8762244d.png)

---

<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:** [October 15, 2019, 12:08pm UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/6 "2019-10-15T12:08:46Z")

</div>

You would have to install the module openpyxl in your Python environment

> pip install openpyxl

or via Anaconda:

[https://anaconda.org/anaconda/openpyxl](https://anaconda.org/anaconda/openpyxl)

---

<div class="post-metadata">

**Author:** ![JinnyLe](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@JinnyLe](https://forum.knime.com/u/JinnyLe)\
**Post date:** [October 18, 2019, 3:41am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/7 "2019-10-18T03:41:50Z")

</div>

hi Ivan,  
Thanks for the guidance. I still run into the same error message even after i have openyxl installed. Do you think there could be another reason?

![image](https://forum-cdn.knime.com/uploads/default/original/2X/8/8a0977d6fabde1bd01a29713e851bf364af11935.png)

---

<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:** [October 18, 2019, 8:32am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/8 "2019-10-18T08:32:24Z")

</div>

This comes to mind:

- check if you actually installed it into your py3\_knime environment instead of the basic anaconda one. To activate it type  
_source activate py3\_knime_
- if the error message is the same it might indicate there still is a problem
- You could clear the KNIME.log and try again to run your workflow and if it fails you could provide us with the log so we might have a look

Bringing KNIME and Python to work together is not so easy sometimes.

---

<div class="post-metadata">

**Author:** ![JinnyLe](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@JinnyLe](https://forum.knime.com/u/JinnyLe)\
**Post date:** [October 24, 2019, 8:01am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/11 "2019-10-24T08:01:53Z")

</div>

Hi Ivan,  
Thanks a ton for being life save. I managed to create the table based on your guidance.

I would want to have another question if there is a node to do conditional formatting for cell value.

For example, if the cell value is above 120 it will be in green color. If below 95 it will be in red. I’m looking at Xls formatting nodes but haven’t found out. Thanks!

I’m thinking of using python with something like- not sure if possible

worksheet.conditional\_format(‘D5:E5’, {‘type’: ‘cell’,  
‘criteria’: ‘greater than’,  
‘value’: 5,  
‘format’: red\_format})  
Regards,  
Jinny

---

<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:** [October 24, 2019, 8:28am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/12 "2019-10-24T08:28:37Z")

</div>

Glad that I could be of any help. Concerning conditional formatting with KNIME and Excel I see two paths:

- the one you mentioned continue using Python or
- try to use the Continental XLS nodes, especially the " XLS Conditional Formatter Node" that seems to do what you want, although I have not used it myself

[https://www.knime.com/community/continental-nodes-for-knime-xls-formatter](https://www.knime.com/community/continental-nodes-for-knime-xls-formatter)

As it is often the case with KNIME there are several ways to do it since KNIME is such an open platform and typically you start with something you feel comfortable with and then continue from there. And your gain experience that will be useful for your next project.

And there is the forum (of course) - and the KNIME hub with a lot of useful examples.

> **[Excel format – KNIME Hub](https://hub.knime.com/search?q=Excel%20format)**
>
> The place to find and collaborate on KNIME workflows and nodes. Here you can find solutions for your data science questions.

---

<div class="post-metadata">

**Author:** ![JinnyLe](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@JinnyLe](https://forum.knime.com/u/JinnyLe)\
**Post date:** [October 24, 2019, 10:11am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/13 "2019-10-24T10:11:35Z")

</div>

hi Ivan,  
I managed to do the conditional color coding 🙂

I have last 2 questions regarding this, it’'s great if you could give me some suggestion

This is the data example i get after export to excel.

![image](https://forum-cdn.knime.com/uploads/default/original/2X/5/59c116b4d018bd635158f9f8670d27b6733d8fae.png)

1. If i want to merge the headers, is Xls cell merger the right node to use?  
 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/2/2422b4a8f800f19a94eef5dbcd29eeb9fbde7fa4.png)

2. Is it possible to extend the column size so that full headers are displayed?  

Thanks so much!  
Jinny

---

<div class="post-metadata">

**Author:** ![ipazin](https://forum-cdn.knime.com/user_avatar/forum.knime.com/ipazin/32/806_2.png) [@ipazin](https://forum.knime.com/u/ipazin)\
**Post date:** [October 24, 2019, 10:18am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/14 "2019-10-24T10:18:35Z")

</div>

Hi there @JinnyLe,

if @mlauber71 is not Ivan then you are thanking the wrong person 😃

I only replied once on beginning and all the credits go to above mentioned user 😉

Br,  
Ivan

---

<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:** [October 24, 2019, 10:23am UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/15 "2019-10-24T10:23:08Z")

</div>

I do not have a specific expertise about cell mergers. You might have to try what the Python package has to offer or the Continental nodes.

Regarding the autosize of columns the standard Excel sheet appender of KNIME does have such a feature - but it used to take forever and sometimes crush the system so I rarely ever use it. Not sure if they fixed that in recent versions. You might give it a try but save your work first.

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

---

<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:** [April 23, 2020, 10:23pm UTC](https://forum.knime.com/t/export-data-to-excel-as-table/18796/16 "2020-04-23T22:23:08Z")

</div>

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