Python Forum
Writing to existing excel sheet
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing to existing excel sheet
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)

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading Excel file and use a wildcard in file name and sheet name randolphoralph 6 209 Jan-13-2022, 10:20 PM
Last Post: randolphoralph
  Python script for excel sheet Nabil 5 1,225 Jun-01-2021, 02:29 PM
Last Post: anuradha
  Copy column from one existing excel file to another file mkujawsk 0 1,058 Apr-14-2021, 06:33 PM
Last Post: mkujawsk
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 2,070 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 961 Mar-24-2021, 04:56 AM
Last Post: shantanu97
  Append excel sheet using openpyxl TammyP 1 920 Feb-02-2021, 06:32 PM
Last Post: nilamo
  How to Copy Single Value From One Excel Sheet to Another SunWers 4 1,147 Dec-29-2020, 05:39 PM
Last Post: SunWers
  Create new Excel instead of update certain sheet Pietertl 1 1,020 Sep-17-2020, 07:04 AM
Last Post: Pietertl
  Edit Open and Active Excel sheet in Python JoeDainton123 1 998 Jul-29-2020, 12:52 AM
Last Post: Larz60+
  copy content of text file with three delimiter into excel sheet vinaykumar 0 888 Jul-12-2020, 01:27 PM
Last Post: vinaykumar

Forum Jump:

User Panel Messages

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