當前位置: 首頁>>代碼示例>>Java>>正文


Java SXSSFWorkbook.dispose方法代碼示例

本文整理匯總了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();
}
 
開發者ID:long47964,項目名稱:excel-utils,代碼行數:20,代碼來源:TestUser.java

示例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();
        }
    }
}
 
開發者ID:To-da,項目名稱:spring-boot-examples,代碼行數:32,代碼來源:PoiExcelWriter.java

示例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();
    }
 
開發者ID:FlyingHe,項目名稱:UtilsMaven,代碼行數:33,代碼來源:Example.java

示例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);
    }
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:23,代碼來源:DataSetExportServicesImpl.java

示例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();
		
	}
 
開發者ID:long47964,項目名稱:excel-utils,代碼行數:26,代碼來源:TestPerson.java


注:本文中的org.apache.poi.xssf.streaming.SXSSFWorkbook.dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。