Free Support Forum - aspose.com

Style.ForegroundColor problem still exists

I have just upgraded to 1.6.1.1 and it seems that the Style.ForegroundColor problem still exists.

No matter what I assign to the property. The cell’s foreground color is black. Is there a fix to be released sometime soon so that I may start using the latest version?

Thanks for your help

Mit freundlichen Grü?en/Best Regards

Kai

Dear Kai,

Thanks for your consideration.

You can only set standard colors in default Color Palette. In MS Excel, in Tools menu, press “Option”, then press the “Color” tab. You can see the 56 standard colors.

The following is the color table:


Color R G B
Black 0 0 0
White 255 255 255
Red 255 0 0
Lime 0 255 0
Blue 0 0 255
Yellow 255 255 0
Magenta 255 0 255
Cyan 0 255 255
Maroon 128 0 0
Green 0 128 0
Navy 0 0 128
Oliver 128 128 0
Purple 128 0 128
Teal 0 128 128
Silver 192 192 192
Gray 128 128 128
Color17 153 153 255
Color18 153 51 102
Color19 255 255 204
Color20 204 255 255
Color21 102 0 102
Color22 255 128 128
Color23 0 102 204
Color24 204 204 255
Color25 0 0 128
Color26 255 0 255
Color27 255 255 0
Color28 0 255 255
Color29 128 0 128
Color30 128 0 0
Color31 0 128 128
Color32 0 0 255
Color33 0 204 255
Color34 204 255 255
Color35 204 255 204
Color36 255 255 153
Color37 153 204 255
Color38 255 153 204
Color39 204 153 255
Color40 255 204 153
Color41 51 102 255
Color42 51 204 204
Color43 153 204 0
Color44 255 204 0
Color45 255 153 0
Color46 255 102 0
Color47 102 102 153
Color48 150 150 150
Color49 0 51 102
Color50 51 153 102
Color51 0 51 0
Color52 51 51 0
Color53 153 51 0
Color54 153 51 102
Color55 51 51 153
Color56 51 51 51

Laurence,

thanks for your reply. However with older versions of Aspose.Excel (i.e. 1.5.7.0) it worked just fine. Also, the examples you ship with 1.6.1.0 set the ForegroundColor to something like Color.Blue etc. and this results in a black cell as well.

Regards

Kai

Dear Kai,

In version 1.5, if you set a color which is not a color in the excel palette, I will change the palette and add this color to palette. Thus the color is added to the result file. But that changes the color palette in the designer file, so another user denied this action.

I think about to add a new method, such as AddColorToPalette. If you want to add a color which is not a standard color, you can call this method to change the palette. How do you think about this idea?

And I have tested that if set the foreground color to Color.Blue, it works fine in 1.6.1.0. So could you post your code here?

Thanks.

Laurence,

thanks for your feedback. I get the point now why it stopped working. I’d prefer getting a method that would allow me to set/add the palette colors rather than relying on the predefined palette colors. This, of course, only in addition to the current behaviour in order not to break existing code.

Apart from that: I have just testet it using 1.6.1.1 assigning Color.FromArgb(204, 204, 255) to the ForgroundColor property which should result in using Color24 of the Excel palette. But the foreground color turns to black using a black font color (which renders it quite unreadable).

In addition to that I have noticed that 1.6.1.1 does not respect a picture’s “Do not move or size with cells” property setting. When calling SetColumnWidth/SetRowHeight the image’s size changes as well even not taking into account aspect ratio. (See my other post regarding this issue).

Looking forward to the additions/fixes.

Regards

Kai

Sorry, not 1.6.1.1 but 1.6.1.0

Dear Kai,

Thanks for your advice.

About the Color.FromArgb(204,204,255), it works fine here. So my question is:
Do you read from a designer file which you totally change the palette?

About the image setting, I reply in that post.

Laurence,

I read from a designer file that I have started from scratch, i.e. no changes to the palette were made. I have also checked that I’m using the correct RGB values when setting the foreground color. I then save the sheet back using Excel97 format.

Regards

Kai

Dear Kai,

Could you send your code and designer file to me? I could not find this problem in my place.

Thank you very much.

Laurence,

sorry, but I found the problem. I was assigning the wrong color which did not map to one of the predefined colors.

Another thing: Could you possible add a property to get the sheet’s (even if loaded from a designer) current palette? Maybe this property could also be use to alter a sheet’s palette.

Regards

Kai

Dear Kai,

In next fix, I will add a property to get the Excel file’s current palette. And two method: one is to decide if a color is in this palette and another is to alter the palette.

And about the problem, please send your designer file and test code to me, thus I can investigate this problem.

Thanks.

Laurence,

sorry that I didn’t make this clear in my earlier post. There is not problem anymore with the designer file and the colors at the moment. I was mapping to a wrong color and that caused the problem.

Looking forward to the next HotFix version.

Regards

Kai

Dear Kai,

Please download hotfix 1.6.2.

I add 2 methods and 1 property to Excel object.

ChangePalette method, IsColorInPalette method, Colors property

Laurence,

thanks for this. Sounds good to me.

Regards

Kai