Python Forum
Writing to existing excel sheet
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing to existing excel sheet
#1
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 = writer.book
worksheet = writer.sheets['Sheet1']
worksheet.write('D15', Total_refund)
worksheet.write('G15', Total_refund)
writer.save()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python best library for Excel reports & review of existing code MasterOfDestr 4 497 Feb-14-2024, 03:39 PM
Last Post: MasterOfDestr
  Python and pandas: Aggregate lines form Excel sheet Glyxbringer 12 1,696 Oct-31-2023, 10:21 AM
Last Post: Pedroski55
  how to read txt file, and write into excel with multiply sheet jacklee26 14 9,515 Jan-21-2023, 06:57 AM
Last Post: jacklee26
  Need Help writing data into Excel format ajitnayak87 8 2,438 Feb-04-2022, 03:00 AM
Last Post: Jeff_t
  Reading Excel file and use a wildcard in file name and sheet name randolphoralph 6 6,857 Jan-13-2022, 10:20 PM
Last Post: randolphoralph
  Python script for excel sheet Nabil 4 3,224 Jun-01-2021, 05:09 AM
Last Post: Pedroski55
  Copy column from one existing excel file to another file mkujawsk 0 5,486 Apr-14-2021, 06:33 PM
Last Post: mkujawsk
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 6,196 Mar-29-2021, 09:36 PM
Last Post: Larz60+
  Add a new column when I extract each sheet in an Excel workbook as a new csv file shantanu97 0 2,191 Mar-24-2021, 04:56 AM
Last Post: shantanu97
  Append excel sheet using openpyxl TammyP 1 2,314 Feb-02-2021, 06:32 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020