I’d like my script to be able to add an extra sheet in an existing workbook with Openpyxl, and then Pandas to write data into that new sheet.
Below is what i have
file_name = 'Numbers.xlsx'
wb = load_workbook(file_name)
last_sheet = wb.worksheets[-1]
index = int(last_sheet.title)
NewSheet = wb.create_sheet(str(index+1))
wb.save(file_name)
df = pd.DataFrame(zip(house_name,description_details,house_price,specs,ratings,cancellation_policy,urls),columns=['Property Name','Description','Price','Specifications','Ratings','Cancellation Policy','Link'])
with pd.ExcelWriter("Numbers.xlsx", engine='openpyxl', mode='a') as writer:
df.to_excel(writer, sheet_name=NewSheet)