Hi All,


I am using the following code to write data into an excel sheet:

# Open the Output Spreadsheet
objExcel = win32com.client.Dispatch("Excel.Application")

# Creating object to write to Spreadsheet    
        self.xlApp =Dispatch("Excel.Application")
                    
        # Creating Workbook
        self.Wkbk = self.xlApp.Workbooks.Add()

        # Get sheet count
        intShtCnt=self.Wkbk.Worksheets.Count

        # Creating worksheets
        wsObjReport = self.Wkbk.Worksheets.Add()

        # Setting names to the sheets
        wsObjReport.Name="Report"
                   
        # Alignment Variables
        xlLeft, xlRight, xlCenter = -4131, -4152, -4108

        # Loop to remove extra sheets(created by default)
        for intiLoopIndex in range(1,intShtCnt+1):
            self.Wkbk.Worksheets("Sheet"+str(intiLoopIndex)).Delete()        

        # Setting active sheet
        sheets = self.Wkbk.Sheets
        sheets("Report").Activate()

I am able to change the default sheet name to "Report". I want to change the color of the excel sheet from WHITE to YELLOW. How can I do it?...
Any help is much appreciated.

Regards,
Dinil

Recommended Answers

All 2 Replies

I am not sure whether you can change the entire sheet color to yellow.
But you can change the colors of individual cells to any color u want.

worksheet.Cells(row,column).interior.colorindex = 6

here 6 is for yellow.

http://www.geocities.com/davemcritchie/excel/colors.htm

you can use the above URL for other color indexes.

Thanks a lot brother.. Its working fine.. I am now able to change the color of each row.
Thanks once again!...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.