1# Using Data-Validation
2# An example using openpyxl with DataValiation
3# more on docs - https://openpyxl.readthedocs.io/en/2.5/validation.html
4from openpyxl import Workbook
5from openpyxl.worksheet.datavalidation import DataValidation
6
7wb = Workbook()
8
9ws = wb.create_sheet('New Sheet')
10
11for number in range(1,100): #Generates 99 "ip" address in the Column A;
12 ws['A{}'.format(number)].value= "192.168.1.{}".format(number)
13
14data_val = DataValidation(type="list",formula1='=$A:$A') #You can change =$A:$A with a smaller range like =A1:A9
15ws.add_data_validation(data_val)
16
17data_val.add(ws["B1"]) #If you go to the cell B1 you will find a drop down list with all the values from the column A
18
19wb.save('Test.xlsx')
20