I am exporting a Excel file with a drop-down list.
For that I am using the code below:
with pd.ExcelWriter('draft.xlsx', engine='xlsxwriter') as writer:
df.to_excel(excel_writer=writer, sheet_name='Filter', index=False)
worksheet = writer.sheets['Filter']
worksheet.data_validation('B:B', {'validate': 'list', 'source': ['open', 'high', 'close']})
I am putting the group'B:B' because I want the drop-down list on all values from the column.
However, when I run this I am getting this:
AttributeError: 'NoneType' object has no attribute 'group'
Is that possible to apply Data Validation on all the column values?
Thanks!
The range 'B:B' isn't supported syntax. You need to specify the entire column range. Like this:
worksheet.data_validation('B1:B1048576',
{'validate': 'list',
'source': ['open', 'high', 'close']})
See also: XlsxWriter - Row and Column Ranges.