Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 导出到Excel文件中的多张图纸_Jsf_Primefaces_Export_Apache Poi_Primefaces Extensions - Fatal编程技术网

Jsf 导出到Excel文件中的多张图纸

Jsf 导出到Excel文件中的多张图纸,jsf,primefaces,export,apache-poi,primefaces-extensions,Jsf,Primefaces,Export,Apache Poi,Primefaces Extensions,我想使用primefaces 4.0或primefaces extension exporter在一个Excel文件中导出多个数据表,每个数据表位于单独的工作表中。可以这样做吗?使用Excel文件处理框架。我认为这仍然是最好的选择之一 例如: public void createExcelReport(OutputStream stream) { WritableWorkbook workbook = null; try { Workboo

我想使用primefaces 4.0或primefaces extension exporter在一个Excel文件中导出多个数据表,每个数据表位于单独的工作表中。可以这样做吗?

使用Excel文件处理框架。我认为这仍然是最好的选择之一

例如:

public void createExcelReport(OutputStream stream) {
        WritableWorkbook workbook = null;
        try {
            Workbook template = Workbook.getWorkbook(new File(getClass().getResource("/report/report_template.xls").getFile()));
            workbook = Workbook.createWorkbook(stream, template);
            WritableSheet sheet = workbook.getSheet(0);
            int idx = START_ROW_IDX;
            for (SomePojo pojo : pojoService.getPojos()) {
                writePojoToRow(pojo);       
                        idx++;
            }
            if (idx == START_ROW_IDX) {
                addNoErrorSheet(sheet);
            }
            workbook.write();
        } catch (Exception e) {
            log.error("There was a problem here.", e);
            throw new RuntimeException("Excel file creation did not work because of this Exception: ", e);
        } finally {
            if (workbook != null) {
                try {
                    workbook.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

我只想在可能的情况下使用primefaces或ApachePOI,因为此页面是更大项目的一部分。谢谢你的建议。获取所有数据并使用ApachePOI在一个文件中创建所有工作表,你认为如何?