Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -re923dff715d473f8bb19d3593f1419662544111c -r7eec5c174998730130370a7a8e2c67cb3c10cee8 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/util/ExcelCell.java =================================================================== diff -u -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 -r7eec5c174998730130370a7a8e2c67cb3c10cee8 --- lams_common/src/java/org/lamsfoundation/lams/util/ExcelCell.java (.../ExcelCell.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) +++ lams_common/src/java/org/lamsfoundation/lams/util/ExcelCell.java (.../ExcelCell.java) (revision 7eec5c174998730130370a7a8e2c67cb3c10cee8) @@ -29,10 +29,14 @@ * Bean object holding necessary data for excel export. */ public class ExcelCell { + + public final static int BORDER_STYLE_LEFT_THIN = 1; + public final static int BORDER_STYLE_RIGHT_THICK = 2; private Object cellValue; private Boolean isBold; private IndexedColors color; + private int borderStyle = 0; public ExcelCell() { } @@ -48,10 +52,16 @@ this.color = color; } - public ExcelCell(Object cellValue, Boolean isBold, IndexedColors color) { + public ExcelCell(Object cellValue, int borderStyle) { this.cellValue = cellValue; + this.isBold = false; + this.borderStyle = borderStyle; + } + + public ExcelCell(Object cellValue, Boolean isBold, int borderStyle) { + this.cellValue = cellValue; this.isBold = isBold; - this.color = color; + this.borderStyle = borderStyle; } public Object getCellValue() { @@ -77,4 +87,12 @@ public void setColor(IndexedColors color) { this.color = color; } + + public int getBorderStyle() { + return borderStyle; + } + + public void setBorderStyle(int borderStyle) { + this.borderStyle = borderStyle; + } } Index: lams_common/src/java/org/lamsfoundation/lams/util/ExcelUtil.java =================================================================== diff -u -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 -r7eec5c174998730130370a7a8e2c67cb3c10cee8 --- lams_common/src/java/org/lamsfoundation/lams/util/ExcelUtil.java (.../ExcelUtil.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) +++ lams_common/src/java/org/lamsfoundation/lams/util/ExcelUtil.java (.../ExcelUtil.java) (revision 7eec5c174998730130370a7a8e2c67cb3c10cee8) @@ -50,6 +50,11 @@ private static CellStyle blueColor; private static CellStyle redColor; private static CellStyle yellowColor; + + private static CellStyle borderStyleLeftThin; + private static CellStyle borderStyleRightThick; + private static CellStyle borderStyleLeftThinBoldFont; + private static CellStyle borderStyleRightThickBoldFont; /** * Create .xlsx file out of provided data and then write out it to an OutputStream. @@ -72,9 +77,9 @@ //create bold style boldStyle = workbook.createCellStyle(); - Font font = workbook.createFont(); - font.setBoldweight(Font.BOLDWEIGHT_BOLD); - boldStyle.setFont(font); + Font boldFont = workbook.createFont(); + boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD); + boldStyle.setFont(boldFont); //create color style blueColor = workbook.createCellStyle(); @@ -90,6 +95,18 @@ yellowColor.setFillForegroundColor(IndexedColors.GOLD.getIndex()); yellowColor.setFillPattern(CellStyle.SOLID_FOREGROUND); + //create border style + borderStyleLeftThin = workbook.createCellStyle(); + borderStyleLeftThin.setBorderLeft(CellStyle.BORDER_THIN); + borderStyleRightThick = workbook.createCellStyle(); + borderStyleRightThick.setBorderRight(CellStyle.BORDER_THICK); + borderStyleLeftThinBoldFont = workbook.createCellStyle(); + borderStyleLeftThinBoldFont.setBorderLeft(CellStyle.BORDER_THIN); + borderStyleLeftThinBoldFont.setFont(boldFont); + borderStyleRightThickBoldFont = workbook.createCellStyle(); + borderStyleRightThickBoldFont.setBorderRight(CellStyle.BORDER_THICK); + borderStyleRightThickBoldFont.setFont(boldFont); + int i = 0; for (String sheetName : dataToExport.keySet()) { if (dataToExport.get(sheetName) != null) { @@ -178,6 +195,30 @@ break; } } + + if (excelCell.getBorderStyle() != 0) { + + switch (excelCell.getBorderStyle()) { + case ExcelCell.BORDER_STYLE_LEFT_THIN: + if (excelCell.isBold()) { + cell.setCellStyle(borderStyleLeftThinBoldFont); + } else { + cell.setCellStyle(borderStyleLeftThin); + } + break; + case ExcelCell.BORDER_STYLE_RIGHT_THICK: + if (excelCell.isBold()) { + cell.setCellStyle(borderStyleRightThickBoldFont); + } else { + cell.setCellStyle(borderStyleRightThick); + } + break; + default: + break; + } + + } + } }