Free Support Forum - aspose.com

Cell Background of the mebedded Excel changes on Activation

I am creating an Excel and setting dme background colors and then embedding it in presentation. If I use Default colors like Color.Red or Color.LightGrey, then the color remain same after activation but if I set any custom color eg. "#DBB85E" then the background changes to some other color.

I am adding this custom color to the workbook usig the code -

Color color = ColorTranslator.FromHtml( "#DBB85E" );

if(!worksheet.Workbook.IsColorInPalette(color))

worksheet.Workbook.ChangePalette(color,40);

Please Suggest.

Hi,

I think you should use Color.FromArgb(…) struct to create the custom colors for your requirement.
e.g
Color color = Color.FromArgb(…, …, …);


Thank you.

I am using the same code ColorTranslator.FromHtml("") to change the color palette and use those colors in the chart. These custome colors work fine. But only when I set this color in the cell background, that it doesn't work.

More over I have values like "#DBB85E" for the colors. So it would not be possible to use the COlor.FromARGB() to convert it to color.

I question is when the same code add custom colors to the paleete which can be used by the charts then it should also work for the cell background.

Hi,

Well, I tried using both ColorTranslator.FromHtml() and Color.FormArgb() methods and they work the same and fine. Attached is my output file.

Following is my sample code:

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
Aspose.Cells.Cell cell = cells[“A1”];
cell.Style.Font.DoubleSize = 8.5;

Color color = ColorTranslator.FromHtml("#DBB85E");
//Or equaivalent rgb color value
//Color color = Color.FromArgb(219,184,94);

sheet.Workbook.ChangePalette(color, 55);
cell.Style.ForegroundColor = color;
cell.Style.Pattern = BackgroundType.Solid;

workbook.Save(“f:\test\Cellsbackfill2.xls”);


Could you create a sample project and post it here to show the issue, we will check it soon.

Thank you.

Please find attached the sample solution to reproduce the issue.

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

I tested your scenario using your sample application with the attached latest version of Aspose.Cells and was unable to reproduce the issue. Your sample application is still using the old version of Aspose.Cells. Please add the new dll and update the reference. Please do let us know if it works fine for you.

Thank You & Best Regards,