Example usage for org.apache.poi.xssf.usermodel XSSFWorkbook write

List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook write

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFWorkbook write.

Prototype

@SuppressWarnings("resource")
public final void write(OutputStream stream) throws IOException 

Source Link

Document

Write out this document to an Outputstream.

Usage

From source file:in.expertsoftware.colorcheck.FormatvarificationErrorList.java

public void dumpFormatErrorToExcelFile(ArrayList<ErrorModel> get_errormodelList)
        throws FileNotFoundException, IOException {
    /***//  w w w .j  ava  2  s  .co m
        Dump the error list into Excel file.***/
    XSSFWorkbook ErrorWorkbook = new XSSFWorkbook();
    XSSFSheet ErrorSheet;
    for (int i = 0; i < get_errormodelList.size(); i++) {
        int index = ErrorWorkbook.getSheetIndex(get_errormodelList.get(i).sheet_name);
        if (index == -1) {
            ErrorSheet = ErrorWorkbook.createSheet(get_errormodelList.get(i).sheet_name);
            XSSFRow totalError = ErrorSheet.createRow(0);
            XSSFRow totalWarning = ErrorSheet.createRow(1);
            CreaateHeaderOfErrorList(ErrorWorkbook, totalError.createCell(0), "Total Errors");
            CreaateHeaderOfErrorList(ErrorWorkbook, totalWarning.createCell(0), "Total Warnings");
            if ((get_errormodelList.get(i).error_level).equals("Warning")) {
                totalWarning.createCell(1).setCellValue(1);
            } else
                totalWarning.createCell(1).setCellValue(0);
            if ((get_errormodelList.get(i).error_level).equals("Error")) {
                totalError.createCell(1).setCellValue(1);
            } else
                totalError.createCell(1).setCellValue(0);

            ErrorSheet.createRow(2);
            XSSFRow headerrow = ErrorSheet.createRow(3);
            //create header of every sheet
            Cell Header_referenceCell = headerrow.createCell(0);
            CreaateHeaderOfErrorList(ErrorWorkbook, Header_referenceCell, "Cell Ref");
            Cell Header_sheetname = headerrow.createCell(1);
            CreaateHeaderOfErrorList(ErrorWorkbook, Header_sheetname, "Sheet Name");
            Cell Header_ErrorDesc = headerrow.createCell(2);
            CreaateHeaderOfErrorList(ErrorWorkbook, Header_ErrorDesc, "Error Description");
            Cell Header_ErrorLevel = headerrow.createCell(3);
            CreaateHeaderOfErrorList(ErrorWorkbook, Header_ErrorLevel, "Error Level");
            XSSFRow row = ErrorSheet.createRow(4);
            row = ErrorSheet.createRow(5);

            CreaateStyleOfErrorList(ErrorWorkbook, row, get_errormodelList.get(i).cell_ref,
                    get_errormodelList.get(i).sheet_name, get_errormodelList.get(i).error_desc,
                    get_errormodelList.get(i).error_level);
            ErrorSheet.autoSizeColumn(0);
            ErrorSheet.autoSizeColumn(1);
            ErrorSheet.autoSizeColumn(2);
            ErrorSheet.autoSizeColumn(3);
        } else {
            printinfo(ErrorWorkbook, get_errormodelList.get(i).cell_ref, get_errormodelList.get(i).sheet_name,
                    get_errormodelList.get(i).error_desc, get_errormodelList.get(i).error_level);
        }
    }
    setColorInfoMetaData(ErrorWorkbook);
    try (FileOutputStream ErrorOutputStream = new FileOutputStream(
            "C:/Users/Dharam/Desktop/DIMT_NEW_CODE/ErrorSheet.xlsx")) {
        ErrorWorkbook.write(ErrorOutputStream);
    }
}

From source file:Interface.interemploi.java

private void writetoxel() {

    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet ws = wb.createSheet();/* w w  w. j av a  2 s.c o m*/

    TreeMap<String, Object[]> data = new TreeMap<>();
    data.put("0",
            new Object[] { mod.getColumnName(0), mod.getColumnName(1), mod.getColumnName(2),
                    mod.getColumnName(3), mod.getColumnName(4), mod.getColumnName(5), mod.getColumnName(6),
                    mod.getColumnName(7), mod.getColumnName(8), mod.getColumnName(9), mod.getColumnName(10),
                    mod.getColumnName(11), mod.getColumnName(12), mod.getColumnName(13), mod.getColumnName(14),
                    mod.getColumnName(15), mod.getColumnName(16), mod.getColumnName(17), mod.getColumnName(18),
                    mod.getColumnName(19) });
    int nb = mod.getRowCount();
    int s = 0;
    for (int i = 1; i <= nb; i++) {
        data.put(Integer.toString(i),
                new Object[] { getvlue(s, 0), getvlue(s, 1), getvlue(s, 2), getvlue(s, 3), getvlue(s, 4),
                        getvlue(s, 5), getvlue(s, 6), getvlue(s, 7), getvlue(s, 8), getvlue(s, 9),
                        getvlue(s, 10), getvlue(s, 11), getvlue(s, 12), getvlue(s, 13), getvlue(s, 14),
                        getvlue(s, 15), getvlue(s, 16), getvlue(s, 17), getvlue(s, 18), getvlue(s, 19) });

        s++;
    }
    Set<String> ids = data.keySet();
    XSSFRow row;
    int rowID = 0;
    for (String key : ids) {
        row = ws.createRow(rowID++);

        Object[] values = data.get(key);
        int cellID = 0;
        for (Object o : values) {
            Cell cell = row.createCell(cellID++);
            cell.setCellValue(o.toString());
        }
    }

    try {
        FileOutputStream fs;

        fs = new FileOutputStream(new File("bdd_Fonctionaire.xlsx"));
        wb.write(fs);
        fs.close();
        JOptionPane.showConfirmDialog(null, "Votre Base De Donnee Est Bien Expoter", "Valider",
                JOptionPane.CLOSED_OPTION);
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("bdd_Fonctionaire.xlsx"));
        } else {
            System.out.println("Open is not supported");
        }
    } catch (FileNotFoundException ex) {
        System.out.println("eruer fichier");
    } catch (IOException ex) {
        System.out.println("eruer fichier");
    }

}

From source file:Interface.interProf.java

private void writetoxel() {

    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet ws = wb.createSheet();//from ww  w.j a  va2s.  co m

    TreeMap<String, Object[]> data = new TreeMap<>();
    data.put("0",
            new Object[] { mod.getColumnName(0), mod.getColumnName(1), mod.getColumnName(2),
                    mod.getColumnName(3), mod.getColumnName(4), mod.getColumnName(5), mod.getColumnName(6),
                    mod.getColumnName(7), mod.getColumnName(8), mod.getColumnName(9), mod.getColumnName(10),
                    mod.getColumnName(11), mod.getColumnName(12), mod.getColumnName(13), mod.getColumnName(14),
                    mod.getColumnName(15), mod.getColumnName(16), mod.getColumnName(17), mod.getColumnName(18),
                    mod.getColumnName(19), mod.getColumnName(20) });
    int nb = mod.getRowCount();
    int s = 0;
    for (int i = 1; i <= nb; i++) {
        data.put(Integer.toString(i), new Object[] { getvlue(s, 0), getvlue(s, 1), getvlue(s, 2), getvlue(s, 3),
                getvlue(s, 4), getvlue(s, 5), getvlue(s, 6), getvlue(s, 7), getvlue(s, 8), getvlue(s, 9),
                getvlue(s, 10), getvlue(s, 11), getvlue(s, 12), getvlue(s, 13), getvlue(s, 14), getvlue(s, 15),
                getvlue(s, 16), getvlue(s, 17), getvlue(s, 18), getvlue(s, 19), getvlue(s, 20) });

        s++;
    }
    Set<String> ids = data.keySet();
    XSSFRow row;
    int rowID = 0;
    for (String key : ids) {
        row = ws.createRow(rowID++);

        Object[] values = data.get(key);
        int cellID = 0;
        for (Object o : values) {
            Cell cell = row.createCell(cellID++);
            cell.setCellValue(o.toString());
        }
    }

    try {
        FileOutputStream fs;

        fs = new FileOutputStream(new File("bdd_prof.xlsx"));
        wb.write(fs);
        fs.close();
        JOptionPane.showConfirmDialog(null, "Votre Base De Donnee Est Bien Expoter", "Valider",
                JOptionPane.CLOSED_OPTION);

        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("bdd_prof.xlsx"));
        } else {
            System.out.println("Open is not supported");
        }

    } catch (FileNotFoundException ex) {
        System.out.println("eruer fichier");
    } catch (IOException ex) {
        System.out.println("eruer fichier");
    }

}

From source file:io.excel.AnnotationExcelIO.java

public void save() {

    resultEditor.annotations.Depot depot = new resultEditor.annotations.Depot();

    try {//from  w  w w .j av  a 2s .  com

        int rowcount = 0;
        File project = env.Parameters.WorkSpace.CurrentProject;

        if (project == null) {
            return;
        }

        XSSFWorkbook wb = new XSSFWorkbook();
        XSSFSheet sheet1 = wb.createSheet("Annotation_by_att");

        //
        XSSFRow row0 = sheet1.createRow(0);
        row0.createCell((short) 0).setCellValue("Project Name");
        row0.createCell((short) 1).setCellValue("Annotation ID");
        row0.createCell((short) 2).setCellValue("Annotation Text");
        row0.createCell((short) 3).setCellValue("Annotation Class");
        row0.createCell((short) 4).setCellValue("Full Span");
        row0.createCell((short) 5).setCellValue("Span Start");
        row0.createCell((short) 6).setCellValue("Span End");
        row0.createCell((short) 7).setCellValue("Created Date");
        row0.createCell((short) 8).setCellValue("Annotator Name");
        row0.createCell((short) 9).setCellValue("Annotator ID");
        row0.createCell((short) 10).setCellValue("Attributes");
        row0.createCell((short) 11).setCellValue("Relaionships");
        row0.createCell((short) 11).setCellValue("Contents");

        for (Article article : depot.getDepot()) {
            if (article == null) {
                continue;
            }
            if (article.annotations == null) {
                continue;
            }

            // go through all annotation for each article
            for (Annotation annotation : article.annotations) {
                if (annotation == null) {
                    continue;
                }

                rowcount++;
                XSSFRow row1 = sheet1.createRow(rowcount);
                // project name
                row1.createCell((short) 0).setCellValue(project.getName());
                // annotation id
                row1.createCell((short) 1).setCellValue(annotation.mentionid);
                // current annotator name                   
                row1.createCell((short) 2).setCellValue(annotation.annotationText);
                // class
                row1.createCell((short) 3).setCellValue(annotation.annotationclass);
                // span info
                row1.createCell((short) 4).setCellValue(annotation.getSpansInText());
                row1.createCell((short) 5).setCellValue(annotation.spanset.getMinimumStart());
                row1.createCell((short) 6).setCellValue(annotation.spanset.getMaximumEnd());
                // create time
                row1.createCell((short) 7).setCellValue(annotation.creationDate);
                // annotator
                row1.createCell((short) 8).setCellValue(annotation.getAnnotator());
                row1.createCell((short) 9).setCellValue(annotation.annotatorid);
                row1.createCell((short) 10).setCellValue(annotation.getAttributeString());
                row1.createCell((short) 11).setCellValue(annotation.getComplexRelationshipString());

                String textcontent = PreLoadDocumentContents.getSurroundText(annotation, article);
                row1.createCell((short) 12).setCellValue(textcontent);
            }

        }

        // BUILD THE FILE NAME
        String filename = project.getAbsolutePath() + File.separatorChar + "AnnotationsInExcel.xlsx";
        System.out.println("Annotation results are saved on MS EXCEL Format:" + filename);

        // OUTPUT THE FILE TO DISK
        FileOutputStream fileOut = new FileOutputStream(filename);
        wb.write(fileOut);
        fileOut.close(); // CLOSE

    } catch (Exception ex) {
        ex.printStackTrace();
    }

}

From source file:iscas.tca.ake.demoapp.mvc.module.tools.fileoperator.ExcelBasic.java

License:Open Source License

public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    //      int i = 1;
    //      XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(filePath));
    //      Sheet sheet1 = xwb.getSheet("Sheet1");
    //      /*from  w  w  w.  j  a v  a2s.  c om*/
    //      Row r1 = sheet1.getRow(1);
    //      //Row r1 = sheet1.createRow(1);
    //      //r1.createCell(1).setCellValue("[1,1]");
    //      
    //      System.out.println("sheet physicalcol"+r1.getPhysicalNumberOfCells());
    //      System.out.println("sheet lastcell"+r1.getLastCellNum());
    //      
    //      assert i==1;
    //      
    //      System.out.println("sheet physicalRow"+sheet1.getPhysicalNumberOfRows());
    //      
    //      xwb.write(new FileOutputStream(filePath));
    //      String filePath = "f:"+File.separator+"wb2.xlsx";
    //      File file = new File(filePath);
    //      System.out.println(file.exists());

    XSSFWorkbook wb = new XSSFWorkbook();
    FileOutputStream fos = new FileOutputStream(filePath);
    wb.write(fos);
    fos.close();

}

From source file:javaapp.generateAnomolies.java

public static void generateAnomolyReport() throws IOException {

    XSSFWorkbook workbook = new XSSFWorkbook();

    HashMap<String, List<String>> hmd = new HashMap<String, List<String>>();
    HashMap<String, List<String>> hmc = new HashMap<String, List<String>>();
    HashMap<String, List<String>> uhmd = new HashMap<String, List<String>>();
    HashMap<String, List<String>> uhmc = new HashMap<String, List<String>>();

    hmd = getAnomolies("transrec", "Debtors", 0);
    hmc = getAnomolies("ctransrec", "Creditors", 1);
    uhmd = getAnomoliesUninv("uninv", "Uninv_Debtors", 2);
    uhmc = getAnomoliesUninv("cuninv", "Uninv_Creditors", 3);

    List ls;//from w w w  .j  a v  a 2  s. c o m
    List ls2, ls3, ls4;

    Font font = workbook.createFont();
    font.setFontHeightInPoints((short) 12);
    font.setFontName("Cambria");

    Font hfont = workbook.createFont();
    hfont.setFontHeightInPoints((short) 12);
    hfont.setFontName("Cambria");

    CellStyle style = workbook.createCellStyle();
    CellStyle hstyle = workbook.createCellStyle();

    style.setFont(font);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);

    hstyle.setFont(font);
    hstyle.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
    hstyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

    //System.out.println(hm);
    XSSFSheet sheet = workbook.createSheet("Debtors");
    XSSFSheet sheet2 = workbook.createSheet("Creditors");
    XSSFSheet sheet3 = workbook.createSheet("Uninv_Debtors");
    XSSFSheet sheet4 = workbook.createSheet("Uninv_Creditors");

    Iterator iterator = hmd.keySet().iterator();

    int rowCount = 0;
    Row row = sheet.createRow(0);
    Cell hcell = row.createCell(1);
    hcell.setCellValue((String) "RPPS");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(2);
    hcell.setCellValue((String) "SVC");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(3);
    hcell.setCellValue((String) "OPEN");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(4);
    hcell.setCellValue((String) "RINVOICE");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(5);
    hcell.setCellValue((String) "CORRECTION");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(6);
    hcell.setCellValue((String) "ADJUST");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(7);
    hcell.setCellValue((String) "O1C");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(8);
    hcell.setCellValue((String) "SETTLED");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(9);
    hcell.setCellValue((String) "ALLOC");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(10);
    hcell.setCellValue((String) "WRITEOFF");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(11);
    hcell.setCellValue((String) "CLOSE");
    hcell.setCellStyle(hstyle);
    hcell = row.createCell(12);
    hcell.setCellValue((String) "RECDIFF");
    hcell.setCellStyle(hstyle);

    while (iterator.hasNext()) {

        row = sheet.createRow(++rowCount);
        int columnCount = 0;
        String field = "";

        String key = iterator.next().toString();
        field = key;
        Cell cell = row.createCell(++columnCount);

        if (field instanceof String) {
            cell.setCellValue((String) field);
            cell.setCellStyle(style);
        }

        //System.out.println(hm.get(key));
        ls = (List<String>) hmd.get(key);
        System.out.println(ls);
        Iterator<String> ite = ls.iterator();
        while (ite.hasNext()) {
            field = ite.next();
            //System.out.println( ite.next() );
            cell = row.createCell(++columnCount);
            if (field instanceof String) {
                cell.setCellValue((String) field);
            }

            cell.setCellStyle(style);

        }

    }

    Iterator iterator2 = hmc.keySet().iterator();
    rowCount = 0;

    while (iterator2.hasNext()) {

        row = sheet2.createRow(++rowCount);
        int columnCount = 0;
        String field = "";

        String key = iterator2.next().toString();
        field = key;
        Cell cell = row.createCell(++columnCount);
        if (field instanceof String) {
            cell.setCellValue((String) field);
            cell.setCellStyle(style);
        }

        //System.out.println(hm.get(key));
        ls2 = (List<String>) hmc.get(key);
        System.out.println(ls2);
        Iterator<String> ite = ls2.iterator();
        while (ite.hasNext()) {
            field = ite.next();
            //System.out.println( ite.next() );
            cell = row.createCell(++columnCount);
            if (field instanceof String) {
                cell.setCellValue((String) field);
                cell.setCellStyle(style);
            }

        }

    }

    // uninv debtors

    Iterator iterator3 = uhmd.keySet().iterator();
    rowCount = 0;

    while (iterator3.hasNext()) {

        row = sheet3.createRow(++rowCount);
        int columnCount = 0;
        String field = "";

        String key = iterator3.next().toString();
        field = key;
        Cell cell = row.createCell(++columnCount);
        if (field instanceof String) {
            cell.setCellValue((String) field);
            cell.setCellStyle(style);
        }

        //System.out.println(hm.get(key));
        ls3 = (List<String>) hmc.get(key);
        System.out.println(ls3);
        Iterator<String> ite = ls3.iterator();
        while (ite.hasNext()) {
            field = ite.next();
            //System.out.println( ite.next() );
            cell = row.createCell(++columnCount);
            if (field instanceof String) {
                cell.setCellValue((String) field);
                cell.setCellStyle(style);
            }

        }

    }

    // uninv creditors

    Iterator iterator4 = uhmc.keySet().iterator();
    rowCount = 0;

    while (iterator4.hasNext()) {

        row = sheet4.createRow(++rowCount);
        int columnCount = 0;
        String field = "";

        String key = iterator4.next().toString();
        field = key;
        Cell cell = row.createCell(++columnCount);
        if (field instanceof String) {
            cell.setCellValue((String) field);
            cell.setCellStyle(style);
        }

        //System.out.println(hm.get(key));
        ls4 = (List<String>) uhmc.get(key);
        System.out.println(ls4);
        Iterator<String> ite = ls4.iterator();
        while (ite.hasNext()) {
            field = ite.next();
            //System.out.println( ite.next() );
            cell = row.createCell(++columnCount);
            if (field instanceof String) {
                cell.setCellValue((String) field);
                cell.setCellStyle(style);
            }

        }

    }
    /*
    Object[][] bookData = {
        {"Head First Java", "Kathy Serria", 79},
        {"Effective Java", "Joshua Bloch", 36},
        {"Clean Code", "Robert martin", 42},
        {"Thinking in Java", "Bruce Eckel", 35},
    };
            
            
            
            
            
     //int rowCount = 0;
    for (Object[] aBook : bookData) {
    Row row = sheet.createRow(++rowCount);
             
    int columnCount = 0;
             
    for (Object field : aBook) {
        Cell cell = row.createCell(++columnCount);
        if (field instanceof String) {
            cell.setCellValue((String) field);
        } else if (field instanceof Integer) {
            cell.setCellValue((Integer) field);
        }
    }
             
    }
            
    */
    // workbook.setSheetName(n, WorkbookUtil.createSafeSheetName("Debtors"));
    try (FileOutputStream outputStream = new FileOutputStream("anomolies/GBRCN_Anomolies_27April.xlsx")) {
        workbook.write(outputStream);
    }

}

From source file:javaapplication1.Graph.java

void export() {

    XSSFWorkbook workbook = new XSSFWorkbook();
    //Create a blank sheet
    XSSFSheet sheet = workbook.createSheet("data");
    //This data needs to be written (Object[])
    Map<String, Object[]> data = new TreeMap<String, Object[]>();
    for (int i = 1; i <= values.length; i++)
        data.put("1", new Object[] { values });
    //Iterate over data and write to sheet
    int rownum = 0;
    Row row = sheet.createRow(rownum++);

    int cellnum = 0;

    for (int i : values) {
        Cell cell = row.createCell(cellnum++);
        cell.setCellValue((Integer) i);
    }/*from w w  w  .  java2  s.  c  om*/

    try {
        //Write the workbook in file system
        FileOutputStream out = new FileOutputStream(new File("data.xlsx"));
        workbook.write(out);
        out.close();

        System.out.println("data.xlsx written successfully on disk.");

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:jlib.tool.Writer.java

public static void write2Excel(List<List> input, String filename) {
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet("Amazon");

    int rowCount = 0;
    for (List aBook : input) {
        Row row = sheet.createRow(rowCount++);

        int columnCount = 0;
        for (Object field : aBook) {
            Cell cell = row.createCell(columnCount++);
            if (field instanceof String) {
                cell.setCellValue((String) field);
            } else if (field instanceof Integer) {
                cell.setCellValue((Integer) field);
            }/*from w w w . j  a  v  a2  s. c o m*/
        }
    }

    try (FileOutputStream outputStream = new FileOutputStream(filename)) {
        workbook.write(outputStream);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Writer.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(Writer.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.ExcelDataLoader.java

License:Open Source License

public static void storeToExcel(File excelFile, DataManager dataManager) throws IOException, SQLException {
    OperationHistoryImpl operationHistory = new OperationHistoryImpl(CSVDataLoader.class, "storeToExcelData");
    operationHistory.setAttribute("Export Dir", excelFile.getAbsolutePath());
    dataManager.getOperationHistories().create(operationHistory);

    Path tempDir = Files.createTempDirectory("metabolome");
    CSVDataLoader.storeToCSVData(tempDir.toFile(), dataManager);

    XSSFWorkbook workbook = new XSSFWorkbook();

    for (String one : CSVDataLoader.MAIN_FILENAMES) {
        copyCSV2Excel(tempDir, workbook, one);
    }//from  w  ww .java2s .  c  om

    for (String one : CSVDataLoader.ADDITIONAL_FILENAMES) {
        copyCSV2Excel(tempDir, workbook, one);
    }

    try (FileOutputStream os = new FileOutputStream(excelFile)) {
        workbook.write(os);
    }
}

From source file:jp.ac.utokyo.rcast.karkinos.summary.SummaryStats.java

License:Apache License

private static void writeexcel(String cb, List<Filebean> list, File outcvs, File outexcel1, boolean bfilter,
        String gr, long caplength, int minrecurrent, String hg) {
    // register to memory DB
    try {/*from  ww w  .j av  a  2  s .c om*/

        XSSFWorkbook wb = new XSSFWorkbook();
        CellStyle cs1 = getCS(wb, 3);
        CellStyle cs2 = getCS(wb, 2);
        CellStyle cs3 = getCS(wb, 1);
        CellStyle[] csa = new CellStyle[] { cs1, cs2, cs3 };

        SummaryDB sb = new SummaryDB(outcvs);

        if (gr != null) {
            sb.loadRef(new File(gr), "generef");
        }

        DataReader dr = new DataReader(list);

        XSSFSheet statsheet = wb.createSheet("AA_cahnge_mutation_by_gene");
        sb.geneStat(dr, statsheet, bfilter, csa, true, wb, caplength, false, minrecurrent, false);

        XSSFSheet statsheetamphd = wb.createSheet("AA_cahnge_mutation_by_gene(AmpHD)");
        sb.geneStat(dr, statsheetamphd, bfilter, csa, true, wb, caplength, true, minrecurrent, false);

        XSSFSheet statsheet_all = wb.createSheet("all_mutation_by_gene");
        sb.geneStat(dr, statsheet_all, bfilter, csa, false, wb, caplength, true, minrecurrent, false);

        //
        XSSFSheet mutationstats = wb.createSheet("mutation_type");
        int colcnt = sb.mutationStat(mutationstats, 0, true, bfilter);
        sb.mutationStat(mutationstats, colcnt + 5, false, bfilter);

        if (hg != null) {
            XSSFSheet mutationsig = wb.createSheet("mutation_signature");
            sb.mutationSig(mutationsig, hg);
        }
        //
        XSSFSheet tumorcontents = wb.createSheet("tumor_contents_ratio");

        DataWriter.writeTr(dr, tumorcontents, sb.getSampleL());

        ChromBand cband = null;
        if (cb != null) {
            cband = new ChromBand(cb);
        }

        XSSFSheet statsheet_HD_amp = wb.createSheet("HD_amp");
        sb.writeHDAMP(dr, statsheet_HD_amp, cband);

        //
        XSSFSheet cnvlist = wb.createSheet("cnvlist");
        DataWriter.writeCNV(dr, cnvlist, sb.getSampleL(), 1);

        XSSFSheet cnvlistal = wb.createSheet("cnvlistAllelic");
        DataWriter.writeCNV(dr, cnvlistal, sb.getSampleL(), 2);

        if (cb != null) {
            //
            XSSFSheet cnvcblist = wb.createSheet("cnvchrbandlist");
            DataWriter.writeCNVCB(dr, cnvcblist, sb.getSampleL(), cband, csa, false);

            XSSFSheet cnvcblistlow = wb.createSheet("cnvchrbandlist(low)");
            DataWriter.writeCNVCBAL(dr, cnvcblistlow, sb.getSampleL(), cband, csa, false);

            XSSFSheet cnvcblisthigh = wb.createSheet("cnvchrbandlist(high)");
            DataWriter.writeCNVCBAL(dr, cnvcblisthigh, sb.getSampleL(), cband, csa, true);

            XSSFSheet cnvcblistf = wb.createSheet("focal_cnvchrbandlist");
            DataWriter.writeCNVCB(dr, cnvcblistf, sb.getSampleL(), cband, csa, true);

            cband.close();
        }

        XSSFSheet rstat = wb.createSheet("readstats");
        DataWriter.writeReadsStats(dr, rstat, sb.getSampleL());

        sb.close();

        FileOutputStream out = new FileOutputStream(outexcel1);
        wb.write(out);
        out.close();

    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}