How do you unset a Style (remove Color)

I have rows that have styles applied to them (background color) when validation fails, and the spreadsheet is sent back to the user for modification.



When they re-upload it, I need to reset the background color on the rows that now pass validation, but I can’t find a way to do that.



If i set the background color to white, it’s still not the same… that overrides the default cell borders that are shown and you get a solid white background just on that row.



Also, FYI… setting color to null with Style.setColor(null), will produce an erroneous Workbook when saved.



Any help would be appreciated.

Hi,

Well, you may try to set PatternStyle to PatternType.NONE if it fits your need to get default shading color for the cells.

Following is sample code to test it:

Sample code:

Workbook workbook = new Workbook();
workbook.open("e:\\files\\mybook.xls");
Cells cells = workbook.getWorksheets().getSheet(0).getCells();
.............

Cell cell = cells.getCell(1, 1);
Style style = cell.getStyle();
style.setPatternStyle(PatternType.NONE);
cell.setStyle(style);


...........
workbook.save("e:\\files\\outbook.xls");

And I think alternatively you may try to implement conditional formattings and set FormatCondition to set the backcolor styles for your requirements too, check the doc topic: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/conditional-formatting.html

Thank you.