本文整理汇总了Java中org.apache.poi.xssf.streaming.SXSSFWorkbook.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java SXSSFWorkbook.dispose方法的具体用法?Java SXSSFWorkbook.dispose怎么用?Java SXSSFWorkbook.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xssf.streaming.SXSSFWorkbook
的用法示例。
在下文中一共展示了SXSSFWorkbook.dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExcel07
import org.apache.poi.xssf.streaming.SXSSFWorkbook; //导入方法依赖的package包/类
@Test
public void testExcel07() throws IOException{
List<UserPlus> list = getData(0, 20000);
Map<String, String> map = new HashMap<String,String>();
map.put("msg", "用户信息导出报表");
map.put("status", "导出成功");
long start = System.currentTimeMillis();
Workbook workbook = ExcelExportUtil.exportExcel07(UserPlus.class, list, map, true);
long end = System.currentTimeMillis();
System.out.println("耗时:" + (end - start ) + "毫秒");
FileOutputStream outputStream = new FileOutputStream("D:/test/user.xlsx");
workbook.write(outputStream);
if(SXSSFWorkbook.class.equals(workbook.getClass())){
SXSSFWorkbook wb = (SXSSFWorkbook)workbook;
wb.dispose();
}
outputStream.flush();
outputStream.close();
}
示例2: process
import org.apache.poi.xssf.streaming.SXSSFWorkbook; //导入方法依赖的package包/类
/**
* could be interesting for spring batch
*
* @param inputResource source of the data read by lines
* @param outputResource generated .xlsx resource
*/
public void process(Resource inputResource, Resource outputResource) {
SXSSFWorkbook wb = new SXSSFWorkbook(flushSize);
try {
wb.setCompressTempFiles(true); // temp files will be gzipped
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) {
// dispose of temporary files backing this workbook on disk
wb.dispose();
}
}
}
示例3: main
import org.apache.poi.xssf.streaming.SXSSFWorkbook; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {
SXSSFWorkbook wb = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk
Sheet sh = wb.createSheet();
for (int rownum = 0; rownum < 1000; rownum++) {
Row row = sh.createRow(rownum);
Row row1 = sh.createRow(rownum);
for (int cellnum = 0; cellnum < 10; cellnum++) {
Cell cell = row.createCell(cellnum);
String address = new CellReference(cell).formatAsString();
cell.setCellValue(address);
}
}
// Rows with rownum < 900 are flushed and not accessible
// for (int rownum = 0; rownum < 103857; rownum++) {
// Assert.assertNull(sh.getRow(rownum));
// }
//
// // ther last 100 rows are still in memory
// for (int rownum = 103857; rownum < 104857; rownum++) {
// Assert.assertNotNull(sh.getRow(rownum));
// }
File file = new File("C:\\Users\\FlyingHe\\Desktop", "datas.xlsx");
FileOutputStream out = new FileOutputStream(file);
wb.write(out);
out.close();
// dispose of temporary files backing this workbook on disk
wb.dispose();
}
示例4: exportDataSetExcel
import org.apache.poi.xssf.streaming.SXSSFWorkbook; //导入方法依赖的package包/类
@Override
public org.uberfire.backend.vfs.Path exportDataSetExcel(DataSet dataSet) {
try {
SXSSFWorkbook wb = dataSetToWorkbook(dataSet);
// Write workbook to Path
String tempXlsFile = uuidGenerator.newUuid() + ".xlsx";
Path tempXlsPath = gitStorage.createTempFile(tempXlsFile);
try (OutputStream os = Files.newOutputStream(tempXlsPath)) {
wb.write(os);
os.flush();
}
// Dispose of temporary files backing this workbook on disk
if (!wb.dispose()) {
log.warn("Could not dispose of temporary file associated to data export!");
}
return Paths.convert(tempXlsPath);
} catch (Exception e) {
throw exceptionManager.handleException(e);
}
}
示例5: exportExcel
import org.apache.poi.xssf.streaming.SXSSFWorkbook; //导入方法依赖的package包/类
@Test
public void exportExcel() throws FileNotFoundException, Exception {
File file = new File("D:/test/test/ppp44.xls");
FileOutputStream outputStream = new FileOutputStream(file);
List<Person> list = getData();
Workbook workbook = null;
long start = System.currentTimeMillis();
workbook = ExcelExportUtil.exportExcel03(Person.class, list);
// workbook = ExcelExportUtil.exportExcel(Person.class,list,ExcelFileType.XLS,null,null,true);
// list = getData();
// workbook = ExcelExportUtil.exportExcel(UserPlus.class,list,ExcelFileType.XLSX,map,workbook,true);
long end = System.currentTimeMillis();
System.out.println("耗时:" + (end-start) + "毫秒");
System.out.println("****************************");
workbook.write(outputStream);
if(SXSSFWorkbook.class.equals(workbook.getClass())){
SXSSFWorkbook wb = (SXSSFWorkbook)workbook;
wb.dispose();
}
outputStream.flush();
outputStream.close();
}