Hi,
I need to set the background color of the entire row
When I do this:
StyleFlag flag = new StyleFlag();
flag.setCellShading(true);
cells.applyRowStyle(rowIndex, getHeaderStyle(), flag);
I get a null pointer exception on the applyRowStyle line. Any ideas what I am doing wrong?
Thanks,
Nathan
Hi Nathan,
Thank you for contacting Aspose support.
I have used the following piece of code against the latest version of Aspose.Cells for Java 8.5.0 to verify your presented scenario. Please note, I am unable to replicate the said exception, in fact the style was applied correctly to the specified row.
Please give a try to the following code on your end. In case the problem persists, please provide us your input spreadsheet along with your complete code (most preferably a sample application) for further investigation.
Java
Workbook sourcebook = new Workbook(“sample.xlsx”);
Worksheet sheet = sourcebook.getWorksheets().get(0);
Cells cells = sheet.getCells();
Style style = sourcebook.createStyle();
style.setForegroundColor(Color.getRed());
style.setPattern(FillPattern.SOLID);
StyleFlag flag = new StyleFlag();
flag.setCellShading(true);
cells.applyRowStyle(0, style, flag);
sourcebook.save(“D:/output.xlsx”);