I'd like to create a simple drop down list in excel using python, that contains :
- the first cell alow me to filter by year :2020 2021 2022 ..2024
- the second cell allow me to filter by month : 1 2 3 ...12
this is my code :
import pandas as pd
import numpy as np
from openpyxl.worksheet.datavalidation import DataValidation
from openpyxl import Workbook
import xlsxwriter
wb = Workbook()
ws = wb.create_sheet('list')
wss = wb.create_sheet('year')
for number in range(1,9): #Generates 10 "date" year in the Column A;
ws['A{}'.format(number)].value= "202{}".format(number)
data_val = DataValidation(type="list",formula1='=$A:$A')
ws.add_data_validation(data_val)
data_val.add(wss["B1"]) # drop down list with all the values
wb.save('date.xlsx')
I don't know how to complete this code , I want to have in sheet 'list ' all the years from 2020 until 2040, and in sheet 'year' to have the drop down list
thank you in advance for your help!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…