Python Forum

Full Version: Writing to existing excel sheet
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

Trying to insert a value into an existing spreadsheet.

I get an error in this line (worksheet = writer.sheets['Sheet1'])

Hope some on is able to help. Thanks

import pandas as pd
File2 =r'C:\template.xlsx'

Total_refund = 100

writer = pd.ExcelWriter(File2, engine='xlsxwriter')
workbook =
worksheet = writer.sheets['Sheet1']
worksheet.write('D15', Total_refund)
worksheet.write('G15', Total_refund)