Skip to content

Instantly share code, notes, and snippets.

@evanmiltenburg
Created June 17, 2019 10:14
Show Gist options
  • Save evanmiltenburg/2cf6adf7d9af55a5bda965be0b576eae to your computer and use it in GitHub Desktop.
Save evanmiltenburg/2cf6adf7d9af55a5bda965be0b576eae to your computer and use it in GitHub Desktop.
Generate an Excel worksheet to provide word-level annotations
import xlsxwriter
# Create workbook with a new worksheet.
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()
# Write the tokens.
worksheet.write('A1', 'Hello')
worksheet.write('B1', 'world')
worksheet.write('C1', '!')
# Define options to choose from.
options = ['A', 'B', 'C']
# Insert the dropdown menu:
for cell in ['A2','B2','C2']:
worksheet.data_validation(cell, {'validate': 'list', 'source': options})
# Write out the data, and close.
workbook.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment