Below I've provided a fully reproducible example of how you can go about modifying an existing .xlsx workbook using pandas and the openpyxl module (link to Openpyxl Docs).

First, for demonstration purposes, I create a workbook called test.xlsx:

from openpyxl import load_workbook
import pandas as pd
writer = pd.ExcelWriter('test.xlsx', engine='openpyxl') 
wb  = writer.book
df = pd.DataFrame({'Col_A': [1,2,3,4],
                  'Col_B': [5,6,7,8],
                  'Col_C': [0,0,0,0],
                  'Col_D': [13,14,15,16]})

df.to_excel(writer, index=False)
wb.save('test.xlsx')

This is the Expected output at this point:

In this second part, we load the existing workbook ('test.xlsx') and modify the third column with different data.

from openpyxl import load_workbook
import pandas as pd
df_new = pd.DataFrame({'Col_C': [9, 10, 11, 12]})
wb = load_workbook('test.xlsx')

ws = wb['Sheet1']

for index, row in df_new.iterrows():
    cell = 'C%d'  % (index + 2)
    ws[cell] = row[0]

wb.save('test.xlsx')

This is the Expected output at the end:

Answer from patrickjlong1 on Stack Overflow
Top answer
1 of 2
18

Below I've provided a fully reproducible example of how you can go about modifying an existing .xlsx workbook using pandas and the openpyxl module (link to Openpyxl Docs).

First, for demonstration purposes, I create a workbook called test.xlsx:

from openpyxl import load_workbook
import pandas as pd
writer = pd.ExcelWriter('test.xlsx', engine='openpyxl') 
wb  = writer.book
df = pd.DataFrame({'Col_A': [1,2,3,4],
                  'Col_B': [5,6,7,8],
                  'Col_C': [0,0,0,0],
                  'Col_D': [13,14,15,16]})

df.to_excel(writer, index=False)
wb.save('test.xlsx')

This is the Expected output at this point:

In this second part, we load the existing workbook ('test.xlsx') and modify the third column with different data.

from openpyxl import load_workbook
import pandas as pd
df_new = pd.DataFrame({'Col_C': [9, 10, 11, 12]})
wb = load_workbook('test.xlsx')

ws = wb['Sheet1']

for index, row in df_new.iterrows():
    cell = 'C%d'  % (index + 2)
    ws[cell] = row[0]

wb.save('test.xlsx')

This is the Expected output at the end:

2 of 2
13

In my opinion, the easiest solution is to read the excel as a panda's dataframe, and modify it and write out as an excel. So for example:

Comments:

Import pandas as pd. Read the excel sheet into pandas data-frame called. Take your data, which could be in a list format, and assign it to the column you want. (just make sure the lengths are the same). Save your data-frame as an excel, either override the old excel or create a new one.

Code:

import pandas as pd
ExcelDataInPandasDataFrame = pd.read_excel("./YourExcel.xlsx")
YourDataInAList = [12.34,17.56,12.45]
ExcelDataInPandasDataFrame ["Col_C"] = YourDataInAList
ExcelDataInPandasDataFrame .to_excel("./YourNewExcel.xlsx",index=False)
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.to_excel.html
pandas.DataFrame.to_excel โ€” pandas 3.0.5 documentation
pandas will check the number of rows, columns, and cell character count does not exceed Excelโ€™s limitations. All other limitations must be checked by the user. ... >>> df1 = pd.DataFrame( ... [["a", "b"], ["c", "d"]], ... index=["row 1", "row 2"], ... columns=["col 1", "col 2"], ... ) >>> df1.to_excel("output.xlsx") ... If you wish to write to more than one sheet in the workbook, it is necessary to specify an ExcelWriter object:
Discussions

python - Write an array in specific column by Pandas to_excel - Stack Overflow
pandas.DataFrame.to_excel documentation says column is optional Columns to write, but I'm wrong, how should the specific column (e.g. More on stackoverflow.com
๐ŸŒ stackoverflow.com
March 17, 2017
excel - Write values to a particular cell in a sheet in pandas in python - Stack Overflow
I have an excel sheet, which already has some values in some cells. For ex :- A B C D 1 val1 val2 val3 2 valx valy I want pandas to w... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to write specific columns to from dataframe to excel? - Stack Overflow
I am trying to write specific columns of the data frame to an excel sheet. My data frame has 3 columns and I only want to write one of those columns to a new sheet. I know this can be done in CSV More on stackoverflow.com
๐ŸŒ stackoverflow.com
python 3.x - How to write to a specific cell in excel using Pandas? - Stack Overflow
I have an excel with columns: Jira ID, TestQuery and TestResult........ This code give me the query to run for given Jira id....... result_df.query("Jira_Num == 'XXXX-01' ")["TestQuery"] .......Output of Query is '110000' ......Now at run time I need to write back the result in TestResult Column Without affecting other sheets in Workbook. 2019-12-20T17:28:11.313Z+00:00 ... Result_df = pandas... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
XlsxWriter
xlsxwriter.readthedocs.io โ€บ example_pandas_column_formats.html
Example: Pandas Excel output with column formatting โ€” XlsxWriter
writer = pd.ExcelWriter("pandas_column_formats.xlsx", engine="xlsxwriter") # Convert the dataframe to an XlsxWriter Excel object. df.to_excel(writer, sheet_name="Sheet1") # Get the xlsxwriter workbook and worksheet objects. workbook = writer.book worksheet = writer.sheets["Sheet1"] # Add some cell formats.
๐ŸŒ
Python Basics
pythonbasics.org โ€บ home โ€บ pandas โ€บ write excel with python pandas
Write Excel with Python Pandas - pythonbasics.org
with pd.ExcelWriter('pandas_to_excel.xlsx') as writer: df.to_excel(writer, sheet_name='sheet1') df2.to_excel(writer, sheet_name='sheet2') You don't need to call writer.save(), writer.close() within the blocks. You can append a DataFrame to an existing Excel file.
๐ŸŒ
Python Land
python.land โ€บ home โ€บ data processing with python โ€บ how to process excel data in python and pandas
How to Process Excel Data in Python and Pandas โ€ข Python Land Tutorial
November 12, 2024 - The startcol parameter takes the column number after which the data should be written, and writes the data to the Excel sheet starting from the specific column. You can observe this in the following example. import pandas as pd # Define a list ...
Find elsewhere
๐ŸŒ
Python Examples
pythonexamples.org โ€บ pandas-write-dataframe-to-excel-sheet
Write Pandas DataFrame to Excel Sheet - Python Examples
You can write the DataFrame to a specific Excel Sheet. The step by step process is: Have your DataFrame ready. Create an Excel Writer with the name of the desired output excel file. Call to_excel() function on the DataFrame with the writer and the name of the Excel Sheet passed as arguments.
Top answer
1 of 4
20

UPDATE2: appending data to existing Excel sheet, preserving other (old) sheets:

import pandas as pd
from openpyxl import load_workbook

fn = r'C:\Temp\.data\doc.xlsx'

df = pd.read_excel(fn, header=None)
df2 = pd.DataFrame({'Data': [13, 24, 35, 46]})

writer = pd.ExcelWriter(fn, engine='openpyxl')
book = load_workbook(fn)
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)

df.to_excel(writer, sheet_name='Sheet1', header=None, index=False)
df2.to_excel(writer, sheet_name='Sheet1', header=None, index=False,
             startcol=7,startrow=6)

writer.save()

UPDATE: your Excel file doesn't have a header, so you should process it accordingly:

In [57]: df = pd.read_excel(fn, header=None)

In [58]: df
Out[58]:
     0    1
0  abc  def
1  ghi  lmn

In [59]: df2
Out[59]:
   Data
0    13
1    24
2    35
3    46

In [60]: writer = pd.ExcelWriter(fn)

In [61]: df.to_excel(writer, header=None, index=False)

In [62]: df2.to_excel(writer, startcol=7,startrow=6, header=None, index=False)

In [63]: writer.save()

OLD answer:

You can use the following trick:

first read the existing contents of the excel file into a new DF:

In [17]: fn = r'C:\Temp\b.xlsx'

In [18]: df = pd.read_excel(fn)

In [19]: df
Out[19]:
       A      B     C      D
0   val1    NaN  val3   val4
1  val11  val22   NaN  val33

now we can write it back and append a new DF2:

In [20]: writer = pd.ExcelWriter(fn)

In [21]: df.to_excel(writer, index=False)

In [22]: df2.to_excel(writer, startcol=7,startrow=6, header=None)

In [23]: writer.save()

2 of 4
14

I was not able to do what was asked by me in the question by using pandas, but was able to solve it by using Openpyxl.

I will write few code snippets which would help in achieving what was asked.

import openpyxl

# to open the excel sheet and if it has macros
srcfile = openpyxl.load_workbook('docname.xlsx', read_only=False, keep_vba=True)

# get sheetname from the file
sheetname = srcfile.get_sheet_by_name('sheetname')
# write something in B2 cell of the supplied sheet
sheetname['B2'] = str('write something')
# write to row 1,col 1 explicitly, this type of writing is useful to
# write something in loops
sheetname.cell(row=1, column=1).value = 'something'

# save it as a new file, the original file is untouched and here I am saving
# it as xlsm(m here denotes macros).
srcfile.save('newfile.xlsm')

So Openpyxl writes to a purticular cell, without touching the other sheets,cells etc. It basically writes to a new file respecting the properties of the original file.

๐ŸŒ
XlsxWriter
xlsxwriter.readthedocs.io โ€บ example_pandas_positioning.html
Example: Pandas Excel dataframe positioning โ€” XlsxWriter
df2.to_excel(writer, sheet_name="Sheet1", startcol=3) df3.to_excel(writer, sheet_name="Sheet1", startrow=6) # It is also possible to write the dataframe without the header and index. df4.to_excel( writer, sheet_name="Sheet1", startrow=7, startcol=4, header=False, index=False ) # Close the Pandas Excel writer and output the Excel file.
๐ŸŒ
datagy
datagy.io โ€บ home โ€บ pandas tutorials โ€บ pandas reading & writing data โ€บ pandas to_excel: writing dataframes to excel files
Pandas to_excel: Writing DataFrames to Excel Files โ€ข datagy
December 15, 2022 - This can be done using the freeze_panes= parameter. The parameter accepts a tuple of integers (of length 2). The tuple represents the bottommost row and the rightmost column that is to be frozen.
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ pandas write to excel with examples
Pandas Write to Excel with Examples - Spark By {Examples}
June 26, 2025 - Use pandas to_excel() function to write a DataFrame to an Excel sheet with extension .xlsx. By default it writes a single DataFrame to an Excel file, you
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ reading-and-writing-excel-files-in-python-with-the-pandas-library
Reading and Writing Excel (XLSX) Files in Python with the Pandas Library
February 27, 2021 - Now, we can use the to_excel() function to write the contents to a file. The only argument is the file path: ... Please note that we are not using any parameters in our example. Therefore, the sheet within the file retains its default name - "Sheet 1". As you can see, our Excel file has an ...
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ pandas โ€บ methods โ€บ to_excel
Pandas to_excel()
import pandas as pd # create DataFrame data = {'Name': ['Tom', 'Nick', 'John'], 'Age': [20, 21, 19], 'City': ['New York', 'London', 'Paris'], 'Salary': [50000, 60000, 55000]} df = pd.DataFrame(data) # save only specific columns to Excel df.to_excel('output.xlsx', columns=['Name', 'Age']) output.xlsx ยท output.xlsx ยท In the example above, we selectively exported only the Name and Age columns of our DataFrame to the output.xlsx Excel file. import pandas as pd # create DataFrame data = {'Name': ['Tom', 'Nick', 'John'], 'Age': [20, 21, 19]} df = pd.DataFrame(data) # write to Excel with index label and freeze the top row df.to_excel('output.xlsx', index_label='ID', freeze_panes=(1,0)) output.xlsx ยท
๐ŸŒ
XlsxWriter
xlsxwriter.readthedocs.io โ€บ working_with_pandas.html
Working with Pandas and XlsxWriter - Read the Docs
import pandas as pd # Create a Pandas dataframe from the data. df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]}) # Create a Pandas Excel writer using XlsxWriter as the engine. writer = pd.ExcelWriter('pandas_simple.xlsx', engine='xlsxwriter') # Convert the dataframe to an XlsxWriter Excel object. df.to_excel(writer, sheet_name='Sheet1') # Close the Pandas Excel writer and output the Excel file. writer.close() The output from this would look like the following: See the full example at Example: Pandas Excel example. In order to apply XlsxWriter features such as Charts, Conditional Formatting and Column Formatting to the Pandas output we need to access the underlying workbook and worksheet objects.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ python_pandas โ€บ python_pandas_to_excel_method.htm
Python Pandas - to_excel() method
merge_cells: Writes MultiIndex ... engine_kwargs: Specifies arbitrary keyword arguments passed to excel engine. The Pandas to_excel() method returns None, instead, it saves the data of Pandas DataFrame or Series into the specified ...
๐ŸŒ
Python Guides
pythonguides.com โ€บ python-pandas-write-dataframe-to-excel
Python Pandas Write To Excel
May 16, 2025 - Learn how to write Pandas DataFrames to Excel files using 5 different methods. Covers basic exports, multiple sheets, formatting, conditional formatting and charts