943,737 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 4506
  • Python RSS
Jun 29th, 2009
0

Excel sheet background color

Expand Post »
Hi All,


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

Python Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 18
Solved Threads: 0
Posting Whiz in Training
dinilkarun is offline Offline
206 posts
since Feb 2008
Jun 29th, 2009
0

Re: Excel sheet background color

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.

Quote ...
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.
Reputation Points: 10
Solved Threads: 6
Junior Poster in Training
xav.vijay is offline Offline
52 posts
since Aug 2005
Jun 30th, 2009
0

Re: Excel sheet background color

Thanks a lot brother.. Its working fine.. I am now able to change the color of each row.
Thanks once again!...
Reputation Points: 18
Solved Threads: 0
Posting Whiz in Training
dinilkarun is offline Offline
206 posts
since Feb 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: How to open PDF file
Next Thread in Python Forum Timeline: python socket tcp/ip program for sending text line from client to server





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC