Change value in Excel using Python

Last Updated : 23 Feb, 2026

Python provides libraries that allow you to read, modify and save Excel files easily. In this article, we will learn how to change the value of a cell in an Excel spreadsheet using Python.

Below are the several methods to perform this task.

Using openpyxl

openpyxl is a Python library used to read and write Excel files in .xlsx, .xlsm, .xltx, and .xltm formats. It works with the modern Office Open XML format and is the most commonly used library for Excel automation in Python. Install it using the below command:

pip install openpyxl

Excel File Used: (sample.xlsx)

To download the file used in this, click here

s2
sample.xlsx
Python
from openpyxl import load_workbook

workbook = load_workbook(filename="sample.xlsx")
sheet = workbook.active
sheet["A1"] = "Full Name"
workbook.save(filename="output.xlsx")

Output

s3

Explanation:

  • workbook = load_workbook(filename="sample.xlsx"): Opens the Excel file.
  • sheet = workbook.active: Selects the active sheet.
  • sheet["A1"] = "Full Name": Updates cell A1 with "Full Name".

Using pandas

pandas can read, modify, and write Excel files easily. It's especially useful when you want to work with multiple cells or large data.

Python
import pandas as pd

df = pd.read_excel("sample.xlsx")
df.at[0, 'Name'] = "Full Name"
df.to_excel("output.xlsx", index=False)

Output

s3

Using xlwings

xlwings can interact with Excel directly through the Excel application. This is useful if you want to update Excel while it's open.

Python
import xlwings as xw

wb = xw.Book("sample.xlsx")
sheet = wb.sheets[0]
sheet.range("A1").value = "Full Name"

wb.save("output.xlsx")
wb.close()

Output

s3

Explanation: sheet.range("A1").value = "Full Name" Updates cell A1 with "Full Name".

Comment