[Tutor] CellColor in excel
janos.juhasz@VELUX.com
janos.juhasz@VELUX.com
Wed Jun 4 11:42:02 2003
Hy All,
can someone show me, how the backgroud color of a cell in MS Excel can =
be
set to RED.
I copied a simple module from the book 'Programming on win32', written=
by
Mark Hammond & Andy Robinson. It is a very nice and usefull book.
import win32com.client
class easyExcel:
def __init__(self, filename=3DNone):
"""Megnyitja az excel f=E1jlt."""
self.xlApp =3D win32com.client.Dispatch('Excel.Application'=
)
self.filename =3D filename
self.xlBook =3D self.xlApp.Workbooks.Open(filename)
def save(self, newfilename=3DNone):
if filename:
self.filename =3D newfilename
self.xlApp.SaveAs(self.filename)
else:
self.xlApp.Save()
def close(self):
self.xlBook.Close(SaveChanges=3D0)
del self.xlApp
def GetCell(self, sheet, row, col):
sht =3D self.xlApp.WorkSheets(sheet)
return sht.Cells(row, col).Value
def SetRed(self, sheet, row, col):
sht =3D self.xlApp.WorkSheets(sheet)
sht.Cells(row, col).ColorIndex =3D 3
But the SetRed function wouldn't like to work :(
I know I had seen example for this, but I did't know where.
Best regards,
-----------------------
Juh=E1sz J=E1nos
IT department
VELUX Magyarorsz=E1g
Fert=F5di =C9p=EDt=F5komponens Kft.
Fert=F5d Malom k=F6z 1.
Phone: +36 99 537 939
Fax: +36 99 537 921
E-Mail: janos.juhasz@VELUX.com
=