Skip to content

Instantly share code, notes, and snippets.

@vmetnev
Created March 15, 2025 14:23
Show Gist options
  • Save vmetnev/0bc889e24afcfe5fe38be3f00822f8c5 to your computer and use it in GitHub Desktop.
Save vmetnev/0bc889e24afcfe5fe38be3f00822f8c5 to your computer and use it in GitHub Desktop.
write to open excel
import pandas as pd
import win32com.client as win32
# Connect to the running instance of Excel
excel = win32.Dispatch("Excel.Application")
workbook = excel.Workbooks("Ex.xlsx") # Name of your workbook
sheet = workbook.Sheets("Q1") # Name of your sheet
# Write data to a specific cell
sheet.Cells(1, 1).Value = "Vladislav22"
print(sheet.Cells(4, 1).Value)
# Save changes (optional)
workbook.Save()
print("ds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment