I am trying to write a password protected excel file with number of sheets. I want each sheet include a separate data frame that I produced as a part of my analysis. I am trying to use openpyxl to do this. Here is the code I have:
from openpyxl import Workbook
import pandas as pd
output1 = pd.DataFrame(df1)
output2 = pd.DataFrame(df2)
output3 = pd.DataFrame(df3)
output4 = pd.DataFrame(df4)
wb = Workbook()
ws1 = wb.create_sheet('Sheet1',0)
ws2 = wb.create_sheet('Sheet1',1)
ws3 = wb.create_sheet('Sheet1')
ws4 = wb.create_sheet('Sheet1')
wb.security.workbookPassword = 'password'
wb.security.lockStructure = True
wb.save(datapath + 'file.xlsx')
So, I think this produces the template I need. However, I am not sure how to assign specific data frames to appropriate sheets within the workbook. Any help would be appreciated.