Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. try {
  2. // creates destination file
  3. File file = new File("test.xlsx");
  4.  
  5. // creates date cells custom style settings
  6. CellStyle dateCellStyle = workbook.createCellStyle();
  7. dateCellStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());
  8. dateCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  9. dateCellStyle.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat("yyyy/MM/dd"));
  10.  
  11. // creates MemPOI using its builder and requests the export
  12. MempoiBuilder.aMemPOI()
  13. .withWorkbook(workbook)
  14. .withFile(file)
  15. .addMempoiSheet(new MempoiSheet(prepStmt))
  16. .withStyleTemplate(new AquaStyleTemplate())
  17. .withNumberCellStyle(workbook.createCellStyle()) // to remove default style you can just override it with a new empty one
  18. .withDateCellStyle(dateCellStyle) // override default date cell style with the new one
  19. .build()
  20. .prepareMempoiReportToFile()
  21. .get();
  22.  
  23. } catch (ExecutionException e) {
  24. System.out.println(e.getCause().getMessage());
  25. } catch (InterruptedException e) {
  26. e.printStackTrace();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement