Excel sheet background color

Thread Solved

Join Date: Feb 2008
Posts: 198
Reputation: dinilkarun is an unknown quantity at this point 
Solved Threads: 0
dinilkarun dinilkarun is offline Offline
Junior Poster

Excel sheet background color

 
0
  #1
Jun 29th, 2009
Hi All,


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

  1. # Open the Output Spreadsheet
  2. objExcel = win32com.client.Dispatch("Excel.Application")
  3.  
  4. # Creating object to write to Spreadsheet
  5. self.xlApp =Dispatch("Excel.Application")
  6.  
  7. # Creating Workbook
  8. self.Wkbk = self.xlApp.Workbooks.Add()
  9.  
  10. # Get sheet count
  11. intShtCnt=self.Wkbk.Worksheets.Count
  12.  
  13. # Creating worksheets
  14. wsObjReport = self.Wkbk.Worksheets.Add()
  15.  
  16. # Setting names to the sheets
  17. wsObjReport.Name="Report"
  18.  
  19. # Alignment Variables
  20. xlLeft, xlRight, xlCenter = -4131, -4152, -4108
  21.  
  22. # Loop to remove extra sheets(created by default)
  23. for intiLoopIndex in range(1,intShtCnt+1):
  24. self.Wkbk.Worksheets("Sheet"+str(intiLoopIndex)).Delete()
  25.  
  26. # Setting active sheet
  27. sheets = self.Wkbk.Sheets
  28. 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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 46
Reputation: xav.vijay is an unknown quantity at this point 
Solved Threads: 6
xav.vijay's Avatar
xav.vijay xav.vijay is offline Offline
Light Poster

Re: Excel sheet background color

 
0
  #2
Jun 29th, 2009
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.
Last edited by xav.vijay; Jun 29th, 2009 at 7:24 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 198
Reputation: dinilkarun is an unknown quantity at this point 
Solved Threads: 0
dinilkarun dinilkarun is offline Offline
Junior Poster

Re: Excel sheet background color

 
0
  #3
Jun 30th, 2009
Thanks a lot brother.. Its working fine.. I am now able to change the color of each row.
Thanks once again!...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC