Example usage for org.apache.poi.hssf.usermodel HSSFSheet groupRow

List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet groupRow

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFSheet groupRow.

Prototype

@Override
public void groupRow(int fromRow, int toRow) 

Source Link

Document

Tie a range of cell together so that they can be collapsed or expanded

Usage

From source file:demo.poi.Outlines.java

License:Apache License

private static void createCase7(String filename) throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");

    sheet1.groupRow(5, 14);
    sheet1.groupRow(7, 10);//from w  w  w .jav a2 s.  c  o m

    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:demo.poi.Outlines.java

License:Apache License

private static void createCase8(String filename) throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");

    sheet1.groupRow(5, 14);
    sheet1.groupRow(7, 10);/*ww  w . ja  v  a  2s .  c o m*/
    sheet1.setRowGroupCollapsed(7, true);

    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:demo.poi.Outlines.java

License:Apache License

private static void createCase9(String filename) throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");

    sheet1.groupRow(5, 14);
    sheet1.groupRow(7, 10);/*from w w w . j a  v a 2  s. com*/
    sheet1.setRowGroupCollapsed(7, true);
    sheet1.setRowGroupCollapsed(5, true);

    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:demo.poi.Outlines.java

License:Apache License

private static void createCase10(String filename) throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");

    sheet1.groupRow(5, 14);
    sheet1.groupRow(7, 10);/*from   w  ww. j a  va2 s .com*/
    sheet1.setRowGroupCollapsed(7, true);
    sheet1.setRowGroupCollapsed(5, true);
    sheet1.setRowGroupCollapsed(8, false);

    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:demo.poi.Outlines.java

License:Apache License

private static void createCase11(String filename) throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");

    sheet1.groupRow(5, 14);
    sheet1.groupRow(7, 10);/*from ww  w  . ja v a  2  s  .c o  m*/
    sheet1.setRowGroupCollapsed(7, true);
    sheet1.setRowGroupCollapsed(5, true);
    sheet1.setRowGroupCollapsed(8, false);
    sheet1.setRowGroupCollapsed(14, false);

    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:demo.poi.Outlines.java

License:Apache License

private static void createCase12(String filename) throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");

    sheet1.groupRow(5, 14);
    sheet1.groupRow(7, 14);/*w  w  w. ja  v a 2  s  . co  m*/
    sheet1.setRowGroupCollapsed(7, true);
    sheet1.setRowGroupCollapsed(5, true);
    sheet1.setRowGroupCollapsed(6, false);

    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:demo.poi.Outlines.java

License:Apache License

private static void createCase13(String filename) throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");

    sheet1.groupRow(5, 14);
    sheet1.groupRow(7, 14);//from   ww w  .j  a va2s  .  co  m
    sheet1.groupRow(16, 19);

    sheet1.groupColumn(4, 7);
    sheet1.groupColumn(9, 12);
    sheet1.groupColumn(10, 11);

    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:org.sourcecodemetrics.report.generators.ClassGenerator.java

License:Open Source License

public static void generate(IClass c, HSSFSheet worksheet, HSSFWorkbook workbook) {
    int startRow = worksheet.getPhysicalNumberOfRows();

    HSSFRow row = worksheet.createRow(worksheet.getPhysicalNumberOfRows());

    // clearing the package level
    HSSFCell cell = row.createCell(0);//from w  ww  .ja  v  a  2s  .  c o  m
    cell.setCellStyle(ReportGeneratorImpl.getWhiteStyle());

    // writing dashes to the invalid metrics
    for (int i = 2; i < ReportGeneratorImpl.headings.size(); i++) {
        HSSFCell ce = row.createCell(i);
        ce.setCellStyle(ReportGeneratorImpl.getDottedYellowStyle());
    }

    // writing the name
    cell = row.createCell(1);
    cell.setCellStyle(ReportGeneratorImpl.getYellowStyle());
    cell.setCellValue(c.getName());

    // writing the metrics
    int colIdx = ReportGeneratorImpl.headings.indexOf("C");
    cell = row.createCell(colIdx);
    cell.setCellStyle(
            c.getC() ? ReportGeneratorImpl.getYellowStyle() : ReportGeneratorImpl.getRedYellowStyle());
    cell.setCellValue(c.getC() ? "yes" : "no");

    colIdx = ReportGeneratorImpl.headings.indexOf("LCC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LCC", "class", (double) c.getLCC());
    cell.setCellValue(c.getLCC());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM1");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LCOM1", "class", (double) c.getLCOM1());
    cell.setCellValue(c.getLCOM1());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM2");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LCOM2", "class", (double) c.getLCOM2());
    cell.setCellValue(c.getLCOM2());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM3");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LCOM3", "class", (double) c.getLCOM3());
    cell.setCellValue(c.getLCOM3());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM4");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LCOM4", "class", (double) c.getLCOM4());
    cell.setCellValue(c.getLCOM4());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM5");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LCOM5", "class", (double) c.getLCOM5());
    cell.setCellValue(c.getLCOM5());

    colIdx = ReportGeneratorImpl.headings.indexOf("NAK");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NAK", "class", (double) c.getNAK());
    cell.setCellValue(c.getNAK());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOF");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOF", "class", (double) c.getNOF());
    cell.setCellValue(c.getNOF());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOM");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOM", "class", (double) c.getNOM());
    cell.setCellValue(c.getNOM());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOSF");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOSF", "class", (double) c.getNOSF());
    cell.setCellValue(c.getNOSF());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOSM");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOSM", "class", (double) c.getNOSM());
    cell.setCellValue(c.getNOSM());

    colIdx = ReportGeneratorImpl.headings.indexOf("NTM");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NTM", "class", (double) c.getNTM());
    cell.setCellValue(c.getNTM());

    colIdx = ReportGeneratorImpl.headings.indexOf("TCC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "TCC", "class", (double) c.getTCC());
    cell.setCellValue(c.getTCC());

    colIdx = ReportGeneratorImpl.headings.indexOf("WMC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "WMC", "class", (double) c.getWMC());
    cell.setCellValue(c.getWMC());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOC", "class", (double) c.getNOC());
    cell.setCellValue(c.getNOC());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOC", "class", (double) c.getLOC());
    cell.setCellValue(c.getLOC());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCm");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOCm", "class", (double) c.getLOCm());
    cell.setCellValue(c.getLOCm());

    // method metrics
    colIdx = ReportGeneratorImpl.headings.indexOf("VG");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "VG", "method", (double) c.getMethodVGAvg());
    cell.setCellValue(c.getMethodVGAvg());

    colIdx = ReportGeneratorImpl.headings.indexOf("NBD");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NBD", "method", (double) c.getMethodNBDAvg());
    cell.setCellValue(c.getMethodNBDAvg());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOP");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOP", "method", (double) c.getMethodNOPSum());
    cell.setCellValue(c.getMethodNOPSum());

    if (c.getMethods().size() > 0) {
        worksheet.createRow(worksheet.getPhysicalNumberOfRows());
    }

    // generate all of the methods
    for (Iterator<IMethod> it = c.getMethods().iterator(); it.hasNext();) {
        IMethod im = it.next();
        MethodGenerator.generate(im, worksheet, workbook);

        if (it.hasNext()) {
            worksheet.createRow(worksheet.getPhysicalNumberOfRows());
        }
    }
    ReportGeneratorImpl.appendEmptyRow(worksheet);

    int endRow = startRow + c.getMethods().size();
    worksheet.groupRow(startRow, endRow);
}

From source file:org.sourcecodemetrics.report.generators.PackageGenerator.java

License:Open Source License

public static void generate(IPackage p, HSSFSheet worksheet, HSSFWorkbook workbook) {
    int startRow = worksheet.getPhysicalNumberOfRows();

    HSSFRow row = worksheet.createRow(worksheet.getPhysicalNumberOfRows());

    // writing the name of the package
    HSSFCell cell = row.createCell(0);/*from w ww.j a  v a 2  s . c om*/
    cell.setCellValue(p.getName());
    cell.setCellStyle(ReportGeneratorImpl.getBlueStyle());

    for (int i = 1; i < ReportGeneratorImpl.headings.size(); i++) {
        HSSFCell c = row.createCell(i);
        c.setCellValue("");
        c.setCellStyle(ReportGeneratorImpl.getDottedBlueStyle());
    }

    int colIdx = ReportGeneratorImpl.headings.indexOf("NCP");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NCP", "package", (double) p.getNCP());
    cell.setCellValue(p.getNCP());

    colIdx = ReportGeneratorImpl.headings.indexOf("NIP");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NIP", "package", (double) p.getNIP());
    cell.setCellValue(p.getNIP());

    colIdx = ReportGeneratorImpl.headings.indexOf("A");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "A", "package", (double) p.getA());
    cell.setCellValue(p.getA());

    colIdx = ReportGeneratorImpl.headings.indexOf("EC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "EC", "package", (double) p.getEC());
    cell.setCellValue(p.getEC());

    colIdx = ReportGeneratorImpl.headings.indexOf("AC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "AC", "package", (double) p.getAC());
    cell.setCellValue(p.getAC());

    colIdx = ReportGeneratorImpl.headings.indexOf("I");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "I", "package", (double) p.getI());
    cell.setCellValue(p.getI());

    colIdx = ReportGeneratorImpl.headings.indexOf("D");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "D", "package", (double) p.getD());
    cell.setCellValue(p.getD());

    colIdx = ReportGeneratorImpl.headings.indexOf("C");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "C", "package", (double) p.getC());
    cell.setCellValue(p.getC());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOC", "package", (double) p.getLOC());
    cell.setCellValue(p.getLOC());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCm");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOCm", "package", (double) p.getLOCm());
    cell.setCellValue(p.getLOCm());

    // class metrics 
    colIdx = ReportGeneratorImpl.headings.indexOf("LCC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LCC", "class", (double) p.getClassLCCAvg());
    cell.setCellValue(p.getClassLCCAvg());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM1");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOCM1", "class", (double) p.getClassLCOM1Avg());
    cell.setCellValue(p.getClassLCOM1Avg());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM2");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOCM2", "class", (double) p.getClassLCOM2Avg());
    cell.setCellValue(p.getClassLCOM2Avg());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM3");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOCM3", "class", (double) p.getClassLCOM3Avg());
    cell.setCellValue(p.getClassLCOM3Avg());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM4");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOCM4", "class", (double) p.getClassLCOM4Avg());
    cell.setCellValue(p.getClassLCOM4Avg());

    colIdx = ReportGeneratorImpl.headings.indexOf("LOCM5");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "LOCM5", "class", (double) p.getClassLCOM5Avg());
    cell.setCellValue(p.getClassLCOM5Avg());

    colIdx = ReportGeneratorImpl.headings.indexOf("NAK");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NAK", "class", (double) p.getClassNAKAvg());
    cell.setCellValue(p.getClassNAKAvg());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOF");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOF", "class", (double) p.getClassNOFSum());
    cell.setCellValue(p.getClassNOFSum());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOM");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOM", "class", (double) p.getClassNOMSum());
    cell.setCellValue(p.getClassNOMSum());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOSF");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOSF", "class", (double) p.getClassNOSFSum());
    cell.setCellValue(p.getClassNOSFSum());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOSM");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOSM", "class", (double) p.getClassNOSMSum());
    cell.setCellValue(p.getClassNOSMSum());

    colIdx = ReportGeneratorImpl.headings.indexOf("NTM");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NTM", "class", (double) p.getClassNTMSum());
    cell.setCellValue(p.getClassNTMSum());

    colIdx = ReportGeneratorImpl.headings.indexOf("TCC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "TCC", "class", (double) p.getClassTCCAvg());
    cell.setCellValue(p.getClassTCCAvg());

    colIdx = ReportGeneratorImpl.headings.indexOf("WMC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "WMC", "class", (double) p.getClassWMCSum());
    cell.setCellValue(p.getClassWMCSum());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOC");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOC", "class", (double) p.getClassNOCSum());
    cell.setCellValue(p.getClassNOCSum());

    // method metrics
    colIdx = ReportGeneratorImpl.headings.indexOf("VG");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "VG", "method", (double) p.getMethodVGAvg());
    cell.setCellValue(p.getMethodVGAvg());

    colIdx = ReportGeneratorImpl.headings.indexOf("NBD");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NBD", "method", (double) p.getMethodNBDAvg());
    cell.setCellValue(p.getMethodNBDAvg());

    colIdx = ReportGeneratorImpl.headings.indexOf("NOP");
    cell = row.createCell(colIdx);
    setCellStyle(cell, "NOP", "method", (double) p.getMethodNOPSum());
    cell.setCellValue(p.getMethodNOPSum());

    // generation of all of the classes
    for (ISourceFile isf : p.getSourceFiles()) {
        for (IClass ic : isf.getClasses()) {
            ClassGenerator.generate(ic, worksheet, workbook);
        }
    }
    ReportGeneratorImpl.appendEmptyRow(worksheet);

    int endRow = worksheet.getPhysicalNumberOfRows() - 2;
    worksheet.groupRow(startRow, endRow);
}

From source file:teamdash.wbs.excel.WBSExcelWriter.java

License:Open Source License

private int writeDataForNodes(HSSFSheet sheet, int rowNum, WBSNode node, TableColumnModel columns) {
    HSSFRow row = sheet.createRow(rowNum);
    writeCellForNodeName(node, row);/*from  ww  w .  ja va  2  s .  com*/
    writeCellsForNodeData(row, node, columns);

    WBSNode[] children = wbs.getChildren(node);
    if (children.length == 0)
        return rowNum;

    int childRowPos = rowNum;
    for (WBSNode child : children) {
        childRowPos = writeDataForNodes(sheet, childRowPos + 1, child, columns);
    }

    sheet.groupRow(rowNum + 1, childRowPos);
    if (!node.isExpanded())
        sheet.setRowGroupCollapsed(rowNum + 1, true);

    return childRowPos;
}