Created
July 11, 2019 15:23
-
-
Save firegloves/d1ecb9a64caa70134975175ff981ab89 to your computer and use it in GitHub Desktop.
MemPOI - Overriding bundled template style
This file contains 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
try { | |
// creates destination file | |
File file = new File("test.xlsx"); | |
// creates date cells custom style settings | |
CellStyle dateCellStyle = workbook.createCellStyle(); | |
dateCellStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex()); | |
dateCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); | |
dateCellStyle.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat("yyyy/MM/dd")); | |
// creates MemPOI using its builder and requests the export | |
MempoiBuilder.aMemPOI() | |
.withWorkbook(workbook) | |
.withFile(file) | |
.addMempoiSheet(new MempoiSheet(prepStmt)) | |
.withStyleTemplate(new AquaStyleTemplate()) | |
.withNumberCellStyle(workbook.createCellStyle()) // to remove default style you can just override it with a new empty one | |
.withDateCellStyle(dateCellStyle) // override default date cell style with the new one | |
.build() | |
.prepareMempoiReportToFile() | |
.get(); | |
} catch (ExecutionException e) { | |
System.out.println(e.getCause().getMessage()); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment