Skip to content

Instantly share code, notes, and snippets.

View firegloves's full-sized avatar
🎯
Everything comes down to a shell script

Luca Corsetti firegloves

🎯
Everything comes down to a shell script
View GitHub Profile
@firegloves
firegloves / MemPOIBundledSubFooter.java
Last active July 11, 2019 15:44
MemPOI - Adding bundled NumberSumSubFooter to the export
try {
// creates MemPOI using its builder and requests the export
MempoiBuilder.aMemPOI()
.withWorkbook(new SXSSFWorkbook())
.addMempoiSheet(new MempoiSheet(prepStmt))
.withStyleTemplate(new ForestStyleTemplate())
.withMempoiSubFooter(new NumberSumSubFooter())
.build()
.prepareMempoiReportToByteArray()
@firegloves
firegloves / MemPOITemplateOverriding.java
Created July 11, 2019 15:23
MemPOI - Overriding bundled template style
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"));
@firegloves
firegloves / MemPOIBasicTemplate.java
Last active July 12, 2019 09:43
MemPOI - Bundled template example
try {
// creates destination file
File file = new File("test.xlsx");
// creates MemPOI using its builder
MemPOI memPOI = MempoiBuilder.aMemPOI()
.withFile(file)
.addMempoiSheet(new MempoiSheet(prepStmt))
.withStyleTemplate(new SummerStyleTemplate())
@firegloves
firegloves / MemPOIMultisheet.java
Last active July 11, 2019 20:49
MemPOI - Multisheet example
try {
// creates destination file
File file = new File("multisheet.xlsx");
// creates sheet 1 with a PreparedStatement and the sheet name
MempoiSheet dogsSheet = MempoiSheetBuilder.aMempoiSheet()
.withSheetName("Dogs sheet")
.withPrepStmt(conn.prepareStatement("SELECT pet_name AS DOG_NAME, pet_race AS DOG_RACE FROM pets WHERE pet_type = 'dog'"))
.build();
@firegloves
firegloves / MemPOIBasicFileName.java
Last active July 11, 2019 14:21
MemPOI - The most basic example returning created filename's String
try {
// creates destination file
File file = new File("test.xlsx");
// creates MemPOI using its builder
MemPOI memPOI = MempoiBuilder.aMemPOI()
.withFile(file)
.addMempoiSheet(new MempoiSheet(prepStmt))
.build();
@firegloves
firegloves / MemPOIBasicByteArray.java
Last active July 11, 2019 14:22
MemPOI - The most basic example returning byte[]
try {
// creates MemPOI using its builder
MemPOI memPOI = MempoiBuilder.aMemPOI()
.addMempoiSheet(new MempoiSheet(prepStmt))
.build();
// exports to byte array
CompletableFuture<byte[]> fut = memPOI.prepareMempoiReportToByteArray();