We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Color of Excel Cell changes after setting style

Hi,

please look at the following code:


workbook.open("Template.xls");
Worksheets worksheets = workbook.getWorksheets();
Worksheet worksheet = worksheets.getSheet(0);
for (Iterator iterator = worksheet.getCells().getCellIterator(); iterator.hasNext();) {
Cell cell = iterator.next();

Style style = cell.getStyle();
style.setCellLocked(false);
cell.setStyle(style);

if (style.getColor().getGreen() != cell.getStyle().getColor().getGreen())
System.out.println(cell.getName() + ": old style: " + style.getColor()
+ " new style: " + cell.getStyle().getColor());
}
workbook.save("Changed color.xls");

and the output:

C4: old style: Color [R=192, G=192, B=192, TINT=0.0, THEME=-1]

new style: Color [R=150, G=150, B=150, TINT=0.0, THEME=-1]

C5: old style: Color [R=192, G=192, B=192, TINT=0.0, THEME=-1]

new style: Color [R=150, G=150, B=150, TINT=0.0, THEME=-1]

C7: old style: Color [R=192, G=192, B=192, TINT=0.0, THEME=-1]

new style: Color [R=150, G=150, B=150, TINT=0.0, THEME=-1]


The colors in "Changed color.xls" after the setting of revised style are now wrong.

What can we do to keep the color?

Thanks,

Inna<span style=“font-family: “Times New Roman”,“serif”;” lang=“EN-US”><o:p></o:p>

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

Please try the attached latest version of Aspose.Cells. I checked your issue with the attached latest version and it works fine.

Thank You & Best Regards,

Thank you. That version works.
Inna