Cell Colours

I'm trying to set the cell colour in a table by using :

m_builder.CellFormat.Shading.ClearFormatting()

m_builder.CellFormat.Shading.Texture = TextureIndex.TextureSolid

m_builder.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(16711680) m_builder.CellFormat.Shading.ForegroundPatternColor = Color.FromArgb(16711680)

This should be a dark red colour but is appearing as black. If I change Color.FromArgb(16711680) to Color.Red the cell correctly appears as red.

Can you tell me what I'm doing wrong?

Thanks,

David

When I check the '16711680' color with the following code:

Color color = Color.FromArgb(16711680);

bool isKnown = color.IsKnownColor;

bool isNamedColor = color.IsNamedColor;

bool isSystemColor = color.IsSystemColor;

it appears that all bool values are false.

More so, if I try to set backcolor of some control to '16711680' like

button3.BackColor = Color.FromArgb(16711680);

I see that the color is not set correctly.

Maybe it is better to use Color.DarkRed instead?

Vladimir,

I would do but need to keep the same colours as in our web application which our customer has specified and they can change through the application at any time. The colours work correctly in our web application but they are being translated to hex values (such as #D6D7D6) before the bgcolor of the cell is set.

If I take the HTML for the table that our application creates on a webform (the word doc is an "output" of the webpage) and use InsertHTML on it the colours are being correctly imported (or at least are very close) - unfortunately the HTML tables formatting goes wrong so we can't use that method. Is there any way to specify a hex value or similar when setting the colour directly?

Thanks,

David

You should really use

Color.FromArgb(255, 0, 0);

instead of

Color.FromArgb(16711680);

Also, if you are having problems with InsertHtml tables formatting and are using the latest version of Aspose.Word please send us the part of your project sufficient to reproduce the problem.

Vladimir,

I am reading the colour values from a field in a table and so am using a single 32bit ARGB value since the table contains both named colours and the colours my customer wants to use. Using a single value is a valid way of creating a colour so I don't see a problem with it.

I am using the latest version so I have attached the HTML that is causing me problems - just do an InsertHTML on it and compare the results to what is shown in IE. Some of the formatting is lost because you don't support the elements that I am using, which is fine, but some of the cells are also lost completely.

Back to my original problem, is there any way to specify a hex value or similar when setting the colour directly since I presume that you are converting/using the hex colour from the HTML in the InsertHTML call to set the imported cells?

Thanks,

David

Using Color.FromArgb(16711680) is equivalent to Color.FromArgb(0, 255, 0, 0) in .NET, which means you are setting alpha channel to full transparnency. I don't think it is what you want. So, if you want to use a single 32bit RGB value at least add 0xFF000000 before using it in Color.FromArgb call.

Vladimir,

You're right that wasn't what I wanted and it works when I set the alpha to 255. It didn't affect the HTML output because the alpha is ignored when its converted.

Thanks for looking at it,

David