I am using POI to generate an Excel File. I need to add borders to specific cells in the worksheet.
How can I accomplish this?
Setting up borders in the style used in the cells will accomplish this. Example:
style.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM); style.setBorderRight(HSSFCellStyle.BORDER_MEDIUM); style.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
In the newer apache poi versions:
XSSFCellStyle style = workbook.createCellStyle(); style.setBorderTop(BorderStyle.MEDIUM); style.setBorderBottom(BorderStyle.MEDIUM); style.setBorderLeft(BorderStyle.MEDIUM); style.setBorderRight(BorderStyle.MEDIUM);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With