Last active
July 1, 2020 02:14
-
-
Save logbasex/2151cfba4a5201acd2a40d25144a5f11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XSSFRow pre = sheet.createRow(0); | |
XSSFCell titleCell = pre.createCell(0); | |
titleCell.setCellType(CellType.STRING); | |
titleCell.setCellValue("Sent Email Detailed Statistics"); | |
XSSFFont font = workbook.createFont(); | |
font.setFontHeightInPoints((short) 25); | |
XSSFCellStyle titleStyle = workbook.createCellStyle(); | |
XSSFColor grey = new XSSFColor(new java.awt.Color(255,195,1)); | |
titleStyle.setFillBackgroundColor(grey); | |
//titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); | |
titleStyle.setFont(font); | |
titleStyle.setAlignment(HorizontalAlignment.CENTER); | |
titleStyle.setWrapText(true); | |
titleCell.setCellStyle(titleStyle); | |
XSSFCell desCell = pre.createCell(2); | |
desCell.setCellType(CellType.STRING); | |
desCell.setCellValue("Details statistics for each email which is already sent."); | |
XSSFFont desFont = workbook.createFont(); | |
desFont.setItalic(true); | |
XSSFCellStyle desStyle = workbook.createCellStyle(); | |
desStyle.setFont(desFont); | |
titleStyle.setWrapText(true); | |
desCell.setCellStyle(desStyle); | |
//merge cell | |
int firstRow = 0; | |
int lastRow = 0; | |
int firstCol = 0; | |
int lastCol = 1; | |
sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol)); | |
//auto size columns include merged cell. | |
sheet.autoSizeColumn(0, true); | |
sheet.autoSizeColumn(1, true); | |
sheet.autoSizeColumn(3, true); | |
sheet.autoSizeColumn(4, true); | |
XSSFRow headerRow = sheet.createRow(1); | |
int i = 0; | |
for (String headerCell : header) { | |
XSSFCell cell = headerRow.createCell(i); | |
cell.setCellType(CellType.STRING); | |
cell.setCellValue(headerCell); | |
sheet.autoSizeColumn(i, true); | |
cell.setCellStyle(style); | |
i++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment