@Test public void testProcess() throws Exception { PoiExcelWriter poiExcelWriter = new PoiExcelWriter(20); final Resource fileSystemResource = new FileSystemResource(destination_file); poiExcelWriter.process(new FileSystemResource(sourceFile), fileSystemResource); XSSFWorkbook xssfWorkbook = new XSSFWorkbook(fileSystemResource.getInputStream()); final XSSFSheet sheetAt = xssfWorkbook.getSheetAt(0); Assert.assertThat("result file is empty", destination_file.length(), not(0l)); Assert.assertThat(sheetAt.getPhysicalNumberOfRows(), is(ROWS_TO_GENERATE)); }
public void process(Resource inputResource, Resource outputResource) { SXSSFWorkbook wb = new SXSSFWorkbook(flushSize); try { wb.setCompressTempFiles(true); final Sheet sh = wb.createSheet(); InputStreamReader is = new InputStreamReader(inputResource.getInputStream()); BufferedReader br = new BufferedReader(is); final CreationHelper createHelper = sh.getWorkbook().getCreationHelper(); br.lines().forEachOrdered(string -> createRow(string, sh, createHelper)); FileOutputStream out = new FileOutputStream(outputResource.getFile()); wb.write(out); IOUtils.closeQuietly(out); } catch (IOException e) { logger.error("IOE", e); } finally { if (wb != null) { wb.dispose(); } } }
PoiExcelWriter { public void process(Resource inputResource, Resource outputResource) { SXSSFWorkbook wb = new SXSSFWorkbook(flushSize); try { wb.setCompressTempFiles(true); final Sheet sh = wb.createSheet(); InputStreamReader is = new InputStreamReader(inputResource.getInputStream()); BufferedReader br = new BufferedReader(is); final CreationHelper createHelper = sh.getWorkbook().getCreationHelper(); br.lines().forEachOrdered(string -> createRow(string, sh, createHelper)); FileOutputStream out = new FileOutputStream(outputResource.getFile()); wb.write(out); IOUtils.closeQuietly(out); } catch (IOException e) { logger.error("IOE", e); } finally { if (wb != null) { wb.dispose(); } } } }
PoiExcelWriter { public void process(Resource inputResource, Resource outputResource) { SXSSFWorkbook wb = new SXSSFWorkbook(flushSize); try { wb.setCompressTempFiles(true); final Sheet sh = wb.createSheet(); InputStreamReader is = new InputStreamReader(inputResource.getInputStream()); BufferedReader br = new BufferedReader(is); final CreationHelper createHelper = sh.getWorkbook().getCreationHelper(); br.lines().forEachOrdered(string -> createRow(string, sh, createHelper)); FileOutputStream out = new FileOutputStream(outputResource.getFile()); wb.write(out); IOUtils.closeQuietly(out); } catch (IOException e) { logger.error("IOE", e); } finally { if (wb != null) { wb.dispose(); } } } PoiExcelWriter(int flushSize); }
PoiExcelWriter { public void process(Resource inputResource, Resource outputResource) { SXSSFWorkbook wb = new SXSSFWorkbook(flushSize); try { wb.setCompressTempFiles(true); final Sheet sh = wb.createSheet(); InputStreamReader is = new InputStreamReader(inputResource.getInputStream()); BufferedReader br = new BufferedReader(is); final CreationHelper createHelper = sh.getWorkbook().getCreationHelper(); br.lines().forEachOrdered(string -> createRow(string, sh, createHelper)); FileOutputStream out = new FileOutputStream(outputResource.getFile()); wb.write(out); IOUtils.closeQuietly(out); } catch (IOException e) { logger.error("IOE", e); } finally { if (wb != null) { wb.dispose(); } } } PoiExcelWriter(int flushSize); void process(Resource inputResource, Resource outputResource); int getFlushSize(); void setFlushSize(int flushSize); }
PoiExcelWriter { public void process(Resource inputResource, Resource outputResource) { SXSSFWorkbook wb = new SXSSFWorkbook(flushSize); try { wb.setCompressTempFiles(true); final Sheet sh = wb.createSheet(); InputStreamReader is = new InputStreamReader(inputResource.getInputStream()); BufferedReader br = new BufferedReader(is); final CreationHelper createHelper = sh.getWorkbook().getCreationHelper(); br.lines().forEachOrdered(string -> createRow(string, sh, createHelper)); FileOutputStream out = new FileOutputStream(outputResource.getFile()); wb.write(out); IOUtils.closeQuietly(out); } catch (IOException e) { logger.error("IOE", e); } finally { if (wb != null) { wb.dispose(); } } } PoiExcelWriter(int flushSize); void process(Resource inputResource, Resource outputResource); int getFlushSize(); void setFlushSize(int flushSize);  }