POIExcelExportUtils { public static AMedia exportSimple(final String reportName, final String sheetName, final List<List<POICell>> cells) throws IOException { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final Workbook workbook = createWorkbook(); return exportSimple(reportName, sheetName, cells, os, workbook); } private  POIExcelExportUtils(); static AMedia getAMediaOutput(final Workbook workbook, final ByteArrayOutputStream os, final String exportName); static AMedia exportSimple(final String reportName, final String sheetName, final List<List<POICell>> cells); static AMedia exportSimple(String reportName, String sheetName, List<List<POICell>> cells, ByteArrayOutputStream os, Workbook workbook); static Cell createCell(Row row, POICell poiCell, int colNum, Workbook workbook); static void autoSizeColumns(Sheet sheet, int cols); static Sheet insertSheet(Workbook workbook, String sheetName); static Workbook createWorkbook(); static ExportResult exportWithResult( String fileName, String sheetName, List<Map<String, Object>> model, int rows, DLListboxExtController masterController );  }
@Test public void testExportSimple() throws Exception { List<List<POICell>> cells = new LinkedList<>(); cells.add(Arrays.asList(new POICell("A number"), new POICell("B date"), new POICell("C text"))); cells.add(Arrays.asList(new POICell(123456), new POICell(new Date()), new POICell("Value C1"))); cells.add(Arrays.asList(new POICell(123456L), new POICell(null), new POICell(""))); cells.add(Arrays.asList(new POICell("loooooong"), new POICell(800195258L), new POICell("-1245654"))); AMedia aMedia = POIExcelExportUtils.exportSimple("report", "sheet", cells); File file = File.createTempFile("test", ".xlsx"); FileOutputStream fos = new FileOutputStream(file); fos.write(aMedia.getByteData()); System.out.println("Test Excel file is here: " + file.getAbsoluteFile()); }