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
  Python script for excel sheet Nabil 5 685 Jun-01-2021, 02:29 PM
Last Post: anuradha
  Copy column from one existing excel file to another file mkujawsk 0 616 Apr-14-2021, 06:33 PM
Last Post: mkujawsk
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 1,171 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 599 Mar-24-2021, 04:56 AM
Last Post: shantanu97
  Append excel sheet using openpyxl TammyP 1 595 Feb-02-2021, 06:32 PM
Last Post: nilamo
  How to Copy Single Value From One Excel Sheet to Another SunWers 4 828 Dec-29-2020, 05:39 PM
Last Post: SunWers
  Create new Excel instead of update certain sheet Pietertl 1 802 Sep-17-2020, 07:04 AM
Last Post: Pietertl
  Edit Open and Active Excel sheet in Python JoeDainton123 1 744 Jul-29-2020, 12:52 AM
Last Post: Larz60+
  copy content of text file with three delimiter into excel sheet vinaykumar 0 628 Jul-12-2020, 01:27 PM
Last Post: vinaykumar
  Excel: Apply formating of a sheet(file1) to another sheet(file2) lowermoon 1 765 May-26-2020, 07:57 AM
Last Post: buran

Forum Jump:

User Panel Messages

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