heading_list= ['apple','type','Action','method']
for j, t in enumerate(heading_list):
worksheet.write(row + 1, col + j, t,header_format)
if t == 'Action':
worksheet.data_validation(row+1,3,col+j,3 ,{'validate': 'list', 'source': ['Insert', 'Update']})
I want to add the validation to the particular row..How will i do?worksheet.data_validation(row+1,3,col+j,3,{'validate': 'list', 'source': ['Insert', 'Update']}) is not working accordingly
The code is working. I think the issue is that the (row, col) co-ordinates are wrong and the data validation isn't in the cell that you expect it to be in.
Fixing the (row, col) co-ordinates should give the expected result:
import xlsxwriter
workbook = xlsxwriter.Workbook('test.xlsx')
worksheet = workbook.add_worksheet()
header_format = workbook.add_format({'border': 1, 'bg_color': '#C6EFCE'})
row = 0
col = 0
heading_list = ['apple', 'type', 'action', 'method']
for j, t in enumerate(heading_list):
worksheet.write(row, col + j, t, header_format)
if t == 'action':
worksheet.data_validation(row + 1, col + j, row + 1, col + j,
{'validate': 'list',
'source': ['Insert', 'Update']})
workbook.close()
Output :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.