# Write excel data file with column with drop down list.

**URL:** <https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937>\
**Category:** KNIME Analytics Platform\
**Created:** [June 30, 2020, 11:59am UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937 "2020-06-30T11:59:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![89trunks](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/8/ea666f/32.png) [@89trunks](https://forum.knime.com/u/89trunks)\
**Post date:** [June 30, 2020, 11:59am UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/1 "2020-06-30T11:59:36Z")

</div>

Hi

I was wondering if there is a not complex way (or any way) to write some data in knime as a xlsx (excel) with added column that contains drop down list. I would like to have excel file that has column where for each row I can choose a predefined option.

For example:  
File is composed of 6 rows of some numbers.

ID  
123  
245  
678  
999  
1234

I would like to add column “extra info” with pre-defined options like: yes, no, not sure.  
Now when someone gets this excel when he clicks on second column for each row he will have option to choose.

ID. extra info  
123. No  
245. No  
678. Yes  
999. Not sure  
1234.

Thanks

---

<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:** [June 30, 2020, 3:41pm UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/2 "2020-06-30T15:41:32Z")

</div>

Yes that is possible with the help of Python and [openpyxl](https://openpyxl.readthedocs.io/en/stable/validation.html)

![image](https://forum-cdn.knime.com/uploads/default/original/3X/1/9/1998cf479e858b2f107f6e8c632d663aa6a2d310.png)

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

> **[Write excel data file with column with drop down list – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/kn_example_python_excel_drop_down~3Ly39rhvI4T6aTTL/current-state)**
>
> Write excel data file with column with drop down list What to edit in the Python code https://forum.knime.com/t/create-a-column-with-drop-down-menu-list/73652/…

You could also check out this thread

> [@DataValidation Drop down list in Excel using Python Scrpt node](https://forum.knime.com/t/datavalidation-drop-down-list-in-excel-using-python-scrpt-node/12648/6):
>
> I attached a workflow that uses your example to create an Excel file via Python. And also one from the example from before. I think you have to provide the Python Script with a valid path (in this case I used the path of the workflow) and you have to close the file at the end. [image] [kn\_example\_python\_excel\_drop\_down.knwf](https://forum-cdn.knime.com/uploads/default/original/2X/3/3d87b7fc29d1017c801cafcd1bf67f72f7c49e9a.knwf) (21.4 KB) – Edit: [KNIME, Python and OpenPyxl](https://medium.com/low-code-for-advanced-data-science/knime-and-excel-an-overview-of-what-you-can-do-c6d400319745#8280)

–  
Edit: [KNIME and Excel — An Overview of What You Can Do | by Markus Lauber | Low Code for Data Science | Medium](https://medium.com/low-code-for-advanced-data-science/knime-and-excel-an-overview-of-what-you-can-do-c6d400319745#8280)

---

<div class="post-metadata">

**Author:** ![89trunks](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/8/ea666f/32.png) [@89trunks](https://forum.knime.com/u/89trunks)\
**Post date:** [June 30, 2020, 8:22pm UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/3 "2020-06-30T20:22:45Z")

</div>

Thanks 🙂 Can you help me to adapt this to my work ? I divide tasks upon some workers:

[KNIME\_project\_dropdownlist.knwf](https://forum.knime.com/uploads/short-url/tsa0Y0PSBs6QU4Kh36exiqh49nh.knwf) (46.7 KB)

I am noob to Python - sorry ☹

Is’t there any other way to do it with some standard nodes? I heard that there is a community extension continental or something like that - but did not find a solution.

---

<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:** [June 30, 2020, 8:55pm UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/4 "2020-06-30T20:55:50Z")

</div>

> [@89trunks](#):
>
> I heard that there is a community extension continental or something like that - but did not find a solution.

I do not know any continental extension that could do what you want.

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

---

<div class="post-metadata">

**Author:** ![89trunks](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/8/ea666f/32.png) [@89trunks](https://forum.knime.com/u/89trunks)\
**Post date:** [July 1, 2020, 11:34am UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/5 "2020-07-01T11:34:15Z")

</div>

Unfortunately there isn’t. Can you help me adopt your concept to my workflow?

---

<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:** [July 1, 2020, 4:11pm UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/6 "2020-07-01T16:11:35Z")

</div>

@89trunks I am not entirely sure what you mean. I checked your workflow and do not understand why you are using the loop. I have adapted the Python code and added some more comments for clarity.

There is no need to loop thru the lines. You would just tell Python openpyxl that the validation rule you have defined should be applied to the area B2:B6. The number of lines is now created dynamically from the data and given to Python by Flow Variable - you could also just set the range by hand if you would know it.

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

---

<div class="post-metadata">

**Author:** ![89trunks](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/8/ea666f/32.png) [@89trunks](https://forum.knime.com/u/89trunks)\
**Post date:** [July 5, 2020, 7:14pm UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/7 "2020-07-05T19:14:50Z")

</div>

Thank you for help - I get the gist of it. The comments really clarify some things.  
BTW: Why I use loops ? Because I have one big data and I have to split it into small files (depending on how many people will be given the tasks) and I wanted each small files to have this drop down list. So I always do it in loops - but never before had to add this drop down list.

Thanks again you are life saver for me.  
Do you recommend some site that explains the Python code just like you did by adding the comments ?

Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![zhengyao](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/z/4491bb/32.png) [@zhengyao](https://forum.knime.com/u/zhengyao)\
**Post date:** [July 6, 2020, 1:50am UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/8 "2020-07-06T01:50:53Z")

</div>

It is a real good solution and works fine.

---

<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:** [July 6, 2020, 6:17am UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/9 "2020-07-06T06:17:55Z")

</div>

If you want to loop thru several files you could think about something like in these examples or you would have to do some other combinations of nodes before and after the python node. Might involve some planning.

> **[Read an XLS file – knime](https://hub.knime.com/knime/spaces/Examples/01_Data_Access/01_Common_Type_Files/07_Reading_Excel_Files~2N5wMVun9Idx8XXO/current-state)**
>
> This workflow demonstrates how to read an XLS file using the XLS Reader node. It contains three workflows. The goal of each workflow is to read accounting data…

> [@89trunks](#):
>
> Do you recommend some site that explains the Python code just like you did by adding the comments ?

There are tons of python courses and introductions out there but ones that do really explain what is going on and why are hard to come by. And then there are very advanced courses with statistical stuff that first throw a bunch of formulas at you and then let you figure out the code by yourself basically.

For machine learning and python the best site and books I have come by is

> **[Machine Learning Mastery](https://machinelearningmastery.com/)**
>
> Making developers awesome at machine learning.

Which gives you working code samples and explainaitions taylored to the task at hand. Of course there is always more to learn and it might not be a general introduction into Python.

About that, one idea if not the most creative one is to take the Kaggle self study course:

> **[Learn Python Tutorials](https://www.kaggle.com/learn/python)**
>
> Learn the most important language for data science.

And then the actual NSA has produced a python course that seems pretty good especially covering a lot of relevant issues, but I have yet to see someone bring that into an actual jupyter notebook instead of a scanned PDF.

[https://www.google.com/search?q=nsa+python+tutorial&ie=UTF-8&oe=UTF-8&hl=de-us&client=safari](https://www.google.com/search?q=nsa+python+tutorial&ie=UTF-8&oe=UTF-8&hl=de-us&client=safari)

And depending on how you like to study, a video course from Udemy or an old fashioned book might be suitable for you.

---

<div class="post-metadata">

**Author:** ![89trunks](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/8/ea666f/32.png) [@89trunks](https://forum.knime.com/u/89trunks)\
**Post date:** [July 6, 2020, 9:42am UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/10 "2020-07-06T09:42:52Z")

</div>

Again thanks for help 😊

---

<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:** [July 13, 2020, 9:42am UTC](https://forum.knime.com/t/write-excel-data-file-with-column-with-drop-down-list/24937/11 "2020-07-13T09:42:58Z")

</div>

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