Knime dropdown

Hello,

I tried to do a dropdown on the FN column(all rows without using range from for example B2 to B10). My code looks like this

import openpyxl
import os
from openpyxl.formula.translate import Translator
from openpyxl.utils import get_column_letter
from openpyxl.styles import Font, Fill
from openpyxl import load_workbook
from openpyxl import Workbook
from openpyxl.worksheet.datavalidation import DataValidation
from openpyxl.worksheet.worksheet import Worksheet
from openpyxl import worksheet

file = flow_variables[‘Name_of_the_file’]
print("file : ",file )
book = openpyxl.load_workbook(file)
sheet = book.worksheets[0]

for s in range(len(book.sheetnames)):
if book.sheetnames[s] == ‘data’:
break
book.active =s
ab = book.active
dv = DataValidation(type=“list”, formula1=’“All, First”’, allow_blank=True)
vr = [“FN2 : FN” + str(sheet.max_column)]
ab.add_data_validation(dv)
dv.add(ab[vr])

Unfortunately I get this error:
lib\site-packages\openpyxl\worksheet\worksheet.py", line 290, in getitem
min_col, min_row, max_col, max_row = range_boundaries(key)
lib\site-packages\openpyxl\utils\cell.py", line 133, in range_boundaries
m = ABSOLUTE_RE.match(range_string)
TypeError: expected string or bytes-like object

Can you help me?

@PawelPablo maybe you could adapt this example:

4 Likes

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