1

Is there any way to modify a few cells in an existing Excel file without losing formatting, and without using xlutils?

I have access to xlwt, and xlrd, but not xlutils.

Thank you!

Andrew R.
  • 25
  • 2
  • It depends on what kind of formatting do you want to keep. E.g. if it's conditional formatting - you'll lose it. – alecxe May 02 '13 at 07:37

1 Answers1

0

Although its use is deprecated nowadays, you can use from win32com.client module which contains "dispatch". It preserves formatting. Example :

from win32com.client import Dispatch
xlApp = Dispatch("Excel.Application")
xlApp.Visible=1
book = xlApp.Workbooks.Open("FileName")
sheet1 = book.Worksheets(1)
sheet1.Cells(1,1).Value="ABC"
user2211059
  • 43
  • 1
  • 4