Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a script that programatically generates excel spreadsheets - cleaning up ugly reports that are given to us from another organisation. For interests sake; I'm using PHPExcel to generate the "clean" reports.

We get these reports every week for an event that happens every couple of months. The reports contain a list of attendees along with a group id that allows us to know that some attendees belong together.

To help the event organisers out, I've taken the event ID and generated a unqiue color code (based on the hash of the event ID - truncated to 6 characters). This unique colour code is set as the background color of a cell in each row. This helps organisers quickly visually identify group members.

Trouble is, when the organisers copy the rows from the weeks report into the master report (which contains all attendees, not just the ones that signed up this week) - all the colour-codes snap to the master template's color pallette.

Thank you very much for your time

All the best Iain

share|improve this question
    
I'm not able to replicate the problem. When I copy and paste a cell, the new cell retains the same background color of the source cell, even if the color is not standard. –  Toc Mar 1 '10 at 14:11
    
That's really interesting. What version of Excel are you using? –  Iain Fraser Mar 2 '10 at 1:08
    
Sorry, my fault. I apologize. Can you link a sheet with some non-standard colours? –  Toc Mar 8 '10 at 15:19
add comment

1 Answer 1

I think the problem is that exact RGB colour values for objects aren't really supported within Excel (at least not in 2003, which I'm also using).

Even if I use Excel VBA to set a cell's background as a particular RGB value, it snaps to the nearest palette entry.

So it looks like although you've worked round this with PHPExcel (not familiar, but assume it's creating XLS files from scratch), as soon as you copy to another sheet, you're limited to the normal Excel behaviour.

This MS Knowledgebase entry describes the issue in Excel 2000 and suggests a workaround using the ShapeRange object in VBA. If you can't address this object in PHPExcel, perhaps you could use VBA to process the files afterwards?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.