"No Fill" property for a cell using Java Code

Hi Team,


I want to set the “No Fill” property of a cell (i.e I9) without setting the foreground color to white.

Also I want to remove the borders of a cell.

Could you please tell me how to achieve this using Java code.

Please find the attached screenshot for the excel property I’m referring to.

Regards,
Sanjeev

Hi,


Thanks for your query.

See the following sample code on how to set No Fill color to the cell:
e.g
Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells objCells = worksheet.getCells();
Style style = workbook.createStyle();
style.setForegroundColor(Color.getEmpty());
style.setPattern(BackgroundType.NONE);
objCells.get(“A1”).setStyle(style);
workbook.save(“out1.xlsx”);

And, see the following sample lines of code on how to remove borders of the cell:
e.g
Sample code:

Border borderBottom = style.getBorders().getByBorderType(BorderType.BOTTOM_BORDER);
Border borderTop = style.getBorders().getByBorderType(BorderType.TOP_BORDER);
Border borderLeft = style.getBorders().getByBorderType(BorderType.LEFT_BORDER);
Border borderRight = style.getBorders().getByBorderType(BorderType.RIGHT_BORDER);
borderBottom.setLineStyle(CellBorderType.NONE);
borderTop.setLineStyle(CellBorderType.NONE);
borderLeft.setLineStyle(CellBorderType.NONE);
borderRight.setLineStyle(CellBorderType.NONE);


Hope, this helps a bit.

Thank you.