When I first saw this question, I had to take a little while and think about it because, if I understand correctly, you are asking whether it is possible to create an alias for a colour within the workbook. This, I understand to mean that you want to substitute one colour for another such that, to take a ridiculously extreme example, whilst the colour red shows in the palatte if the user applies it to a cell/font/border they will actually see the colour green appearing. Is this really what you are after? If so, then the answer is no, there is no mechanism to support this within the api. Furthermore, I have checked within Excel itself and cannot find this mechanism within that application although I would imagine that it could be progrmmed using a macro and VBA code if the cell supprts a listener mechanism that could capture the users interaction for example. It is possible to create custom colours but not subsitiute one colour for another in the way you are describing as far as I can discover.
If, on the other hand, you are asking whether it is possible to create custom colours and apply them to a font/border/cell within the api then the answer is a qualified yes. Qualified because XSSF supports this - constructors exist for the XSSFColor class that allow you to pass either an instance of the java.awt.Color class, or an array of bytes that encapsulate the RGB colour balance. HSSF unfortunately limits your colour choices to just those available within Excel's standard palatte of colours and declares a series of constants with the HSSFColor class to make setting the colour of a font/cell/border much easier. If you have a set of colours that are custom deisgend and that you have to use within a sheet - I can imagine that c compnay may want to match certain elements to colours in their logo for instance, then you could always use the template trick again. Simply create a template that has a hidden sheet. Cell on this sheet could have their colour set specifically using Excel and it should then be possible, at runtime, to pick these up using POI. I say 'should' as I have never tried this myself but it ought to be easy enough to test out. To make the process even eaiser, you could even create names for these cells that describe the colour they hold. Then, when you came to read than, you could simply access each using it's name. This would help to make the purpose of the colour more readilly apparant and introduce an element of 'self-documentation' but this wrinkle is far from necessary. Yours Mark B -- View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-set-RGB-value-for-the-specified-colour-to-a-workbook-tp3369098p3370894.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
