Example usage for org.apache.poi.ss.usermodel Sheet createRow

List of usage examples for org.apache.poi.ss.usermodel Sheet createRow

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Sheet createRow.

Prototype

Row createRow(int rownum);

Source Link

Document

Create a new row within the sheet and return the high level representation

Usage

From source file:com.netxforge.netxstudio.server.logic.reporting.RFSServiceDashboardReportingLogic.java

License:Open Source License

/**
 * Write each NodeType into a separate column, starting from the
 * <code>NODETYPE_ROW</code>
 *///from w  w  w.ja v a 2s . co m
@Override
protected void writeContent(Sheet sheet, NodeType nodeType) {

    Row ntRow = sheet.getRow(NODETYPE_ROW);
    if (ntRow == null) {
        ntRow = sheet.createRow(NODETYPE_ROW);
    }

    Cell ntCell = null;

    if (ntRow.getLastCellNum() == -1) {
        // This is our first node type.
        ntCell = ntRow.createCell(NODE_COLUMN);
    } else {
        ntCell = ntRow.createCell(ntRow.getLastCellNum() + 3);
    }
    if (ntCell != null) {
        ntCell.setCellValue(nodeType.getName());
    }
}

From source file:com.netxforge.netxstudio.server.logic.reporting.RFSServiceDashboardReportingLogic.java

License:Open Source License

/**
 * Write each Node per NodeType column, starting
 *///  w w  w . ja v  a 2s. co  m
@Override
protected void writeContent(Sheet sheet, Service service, Node node, int row, int column) {

    // Write the NODE.ID box.
    int newRow = NODE_ROW + (row * NODE_HEIGHT);
    int nodeColumn = NODE_COLUMN + (column * NODE_WIDTH);

    sheet.setColumnWidth(nodeColumn, 10 * 256);

    CellStyle nodeStyle = this.getWorkBook().createCellStyle();
    nodeStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
    nodeStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);
    nodeStyle.setBorderLeft(CellStyle.BORDER_MEDIUM);
    nodeStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
    nodeStyle.setAlignment(CellStyle.ALIGN_CENTER);
    nodeStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

    {
        Row cellRow = sheet.getRow(newRow);
        if (cellRow == null) {
            cellRow = sheet.createRow(newRow);
        }
        Cell c1 = cellRow.createCell(nodeColumn);
        c1.setCellValue(node.getNodeID());
        c1.setCellStyle(nodeStyle);
    }
    {
        Row cellRow = sheet.getRow(newRow + 1);
        if (cellRow == null) {
            cellRow = sheet.createRow(newRow + 1);
        }
        Cell c1 = cellRow.createCell(nodeColumn);
        c1.setCellStyle(nodeStyle);
    }
    {
        Row cellRow = sheet.getRow(newRow + 2);
        if (cellRow == null) {
            cellRow = sheet.createRow(newRow + 2);
        }
        Cell c1 = cellRow.createCell(nodeColumn);
        c1.setCellStyle(nodeStyle);
    }

    sheet.addMergedRegion(new CellRangeAddress(newRow, newRow + NODE_HEIGHT - 2, nodeColumn, nodeColumn));

    // In between column.
    sheet.setColumnWidth(nodeColumn + 1, 2 * 256);

    // Write the RAG

    CellStyle ragStyle = this.getWorkBook().createCellStyle();

    ragStyle.setBorderTop(CellStyle.BORDER_THIN);
    ragStyle.setBorderBottom(CellStyle.BORDER_THIN);
    ragStyle.setBorderLeft(CellStyle.BORDER_THIN);
    ragStyle.setBorderRight(CellStyle.BORDER_THIN);
    ragStyle.setAlignment(CellStyle.ALIGN_CENTER);
    ragStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    ragStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

    int ragColumn = nodeColumn + 2;
    sheet.setColumnWidth(ragColumn, 2 * 256);

    IMonitoringSummary summary = monStateModel.summary(new NullProgressMonitor(), node,
            new IComputationContext[] { new ObjectContext<Service>(service),
                    new ObjectContext<DateTimeRange>(getPeriod()) });
    if (summary == null) {
        return;
    }
    int[] rag = summary.rag();
    {
        Row cellRow = sheet.getRow(newRow);
        if (cellRow == null) {
            cellRow = sheet.createRow(newRow);
        }
        Cell c1 = cellRow.createCell(ragColumn);

        c1.setCellValue("R");

        CellStyle rStyle = this.getWorkBook().createCellStyle();
        rStyle.cloneStyleFrom(ragStyle);
        rStyle.setFillForegroundColor(IndexedColors.RED.getIndex());
        c1.setCellStyle(rStyle);

        if (rag != null) {
            c1.setCellValue(rag[0]);
        }
    }
    {
        Row cellRow = sheet.getRow(newRow + 1);
        if (cellRow == null) {
            cellRow = sheet.createRow(newRow + 1);
        }
        Cell c1 = cellRow.createCell(ragColumn);

        c1.setCellValue("A");

        CellStyle aStyle = this.getWorkBook().createCellStyle();
        aStyle.cloneStyleFrom(ragStyle);
        aStyle.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
        c1.setCellStyle(aStyle);

        if (rag != null) {
            c1.setCellValue(rag[1]);
        }
    }
    {
        Row cellRow = sheet.getRow(newRow + 2);
        if (cellRow == null) {
            cellRow = sheet.createRow(newRow + 2);
        }
        Cell c1 = cellRow.createCell(ragColumn);
        c1.setCellValue("G");
        CellStyle gStyle = this.getWorkBook().createCellStyle();
        gStyle.cloneStyleFrom(ragStyle);
        gStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());
        c1.setCellStyle(gStyle);

        if (rag != null) {
            c1.setCellValue(rag[2]);
        }

    }
    // Clean our adapted summary.
    node.eAdapters().remove(summary);

}

From source file:com.netxforge.netxstudio.server.logic.reporting.RFSServiceSummaryReportingLogic.java

License:Open Source License

private void writeSummary(Sheet sheet) {

    // Title/*from  w  w  w .j a va 2 s.  c  o  m*/
    Row summaryRow = sheet.createRow(CONTENT_ROW);
    Cell summaryCell = summaryRow.createCell(2);
    summaryCell.setCellValue("Executive Summary");
    sheet.addMergedRegion(new CellRangeAddress(CONTENT_ROW, CONTENT_ROW, 2, 4));

    // Table
    CellStyle borderStyle = this.getWorkBook().createCellStyle();
    borderStyle.setBorderTop(CellStyle.BORDER_THIN);
    borderStyle.setBorderBottom(CellStyle.BORDER_THIN);
    borderStyle.setBorderLeft(CellStyle.BORDER_THIN);
    borderStyle.setBorderRight(CellStyle.BORDER_THIN);
    borderStyle.setAlignment(CellStyle.ALIGN_CENTER);
    borderStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

    Row headerRow = sheet.createRow(HEADER_ROW);
    {
        Cell c1 = headerRow.createCell(4);
        c1.setCellValue("Quantity");
        c1.setCellStyle(borderStyle);
    }

    {
        Cell c1 = headerRow.createCell(5);
        c1.setCellValue("RED");
        c1.setCellStyle(borderStyle);
    }

    {
        Cell c1 = headerRow.createCell(6);
        c1.setCellValue("AMBER");
        c1.setCellStyle(borderStyle);
    }

    {
        Cell c1 = headerRow.createCell(7);
        c1.setCellValue("GREEN");
        c1.setCellStyle(borderStyle);
    }

    writeServicesSummary(sheet, borderStyle);
    writeNodesSummary(sheet, borderStyle);
    writeResourcesSummary(sheet, borderStyle);

}

From source file:com.netxforge.netxstudio.server.logic.reporting.RFSServiceSummaryReportingLogic.java

License:Open Source License

private void writeServicesSummary(Sheet sheet, CellStyle borderStyle) {
    Row servicesRow = sheet.createRow(SERVICES_ROW);

    {/*from   w  ww . ja  v a2s  . c om*/
        Cell c1 = servicesRow.createCell(2);
        c1.setCellValue("#Services");

    }
    { // QUANTITY
        Cell c1 = servicesRow.createCell(4);
        c1.setCellStyle(borderStyle);

        // CB TODO.
        // c1.setCellValue(opSummary.totalServices());
        this.getServices().size();
    }

    { // RED
        Cell c1 = servicesRow.createCell(5);
        c1.setCellStyle(borderStyle);
        c1.setCellValue(opSummary.totalRag(RAG.RED));
    }

    { // AMBER
        Cell c1 = servicesRow.createCell(6);
        c1.setCellStyle(borderStyle);
        c1.setCellValue(opSummary.totalRag(RAG.AMBER));
    }

    { // GREEN
        Cell c1 = servicesRow.createCell(7);
        c1.setCellStyle(borderStyle);
        c1.setCellValue(opSummary.totalRag(RAG.GREEN));
    }
}

From source file:com.netxforge.netxstudio.server.logic.reporting.RFSServiceSummaryReportingLogic.java

License:Open Source License

private void writeNodesSummary(Sheet sheet, CellStyle borderStyle) {
    Row nodesRow = sheet.createRow(NODES_ROW);

    {/* w  w  w  .j a  v a2s  .c om*/
        Cell c1 = nodesRow.createCell(2);
        c1.setCellValue("#Nodes");
    }
    {
        Cell c1 = nodesRow.createCell(4);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalNodes());
    }

    {
        Cell c1 = nodesRow.createCell(5);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalNodeRag(RAG.RED));
    }

    {
        Cell c1 = nodesRow.createCell(6);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalNodeRag(RAG.AMBER));
    }

    {
        Cell c1 = nodesRow.createCell(7);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalNodeRag(RAG.GREEN));
    }
}

From source file:com.netxforge.netxstudio.server.logic.reporting.RFSServiceSummaryReportingLogic.java

License:Open Source License

private void writeResourcesSummary(Sheet sheet, CellStyle borderStyle) {
    Row resourcesRow = sheet.createRow(RESOURCES_ROW);

    {/*from   ww  w  .  j a v a  2s. c  o m*/
        Cell c1 = resourcesRow.createCell(2);
        c1.setCellValue("#Resources");
    }
    {
        Cell c1 = resourcesRow.createCell(4);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalResources());
    }

    {
        Cell c1 = resourcesRow.createCell(5);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalNetXResourceRag(RAG.RED));
    }

    {
        Cell c1 = resourcesRow.createCell(6);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalNetXResourceRag(RAG.AMBER));
    }

    {
        Cell c1 = resourcesRow.createCell(7);
        c1.setCellStyle(borderStyle);
        // CB TODO
        // c1.setCellValue(opSummary.totalNetXResourceRag(RAG.GREEN));
    }
}

From source file:com.netxforge.netxstudio.server.reporting.RFSServiceResourceEmitter.java

License:Open Source License

@Override
public void writeFinal() {

    Sheet sheet = getSheet();

    Row row = sheet.getRow(INFO_ROW);/*from   ww w .  j ava 2  s .com*/
    if (row == null) {
        row = sheet.createRow(INFO_ROW);
    }
    Cell nodeSkippedInfoCell = row.createCell(INFO_COLUMN);
    nodeSkippedInfoCell.setCellValue("Number of not-reported nodes (RAG Appropriate):" + this.nodesNotReported);

    Row componentsRow = sheet.getRow(INFO_ROW + 1);
    if (componentsRow == null) {
        componentsRow = sheet.createRow(INFO_ROW + 1);
    }
    Cell componentsSkippedInfoCell = componentsRow.createCell(INFO_COLUMN);
    componentsSkippedInfoCell
            .setCellValue("Number of not-reported Components (RAG Appropriate):" + this.componentsNotReported);

}

From source file:com.NRC.NMEA.main.NMEA.java

public static void createExcelFile() throws IOException {
    Workbook wb = new XSSFWorkbook();
    FileOutputStream fileOut = new FileOutputStream("C:\\Users\\Noah\\Desktop\\Excel stuff\\Data.xlsx");
    ;/*from   w ww . j  av  a 2 s  .  co m*/
    Sheet PSheet = wb.createSheet("Position Data");
    Sheet ESheet = wb.createSheet("Elevation Data");
    Sheet AbESheet = wb.createSheet("Absolute Elevation Data");
    Sheet DSheet = wb.createSheet("Chart Data");
    DSheet = writeStatInfoToExcel(DSheet);

    {
        AbESheet = writeAbsElevationsToExcel(pControl, AbESheet, 0);
        AbESheet = writeAbsElevationsToExcel(test1, AbESheet, 4);
        AbESheet = writeAbsElevationsToExcel(test2, AbESheet, 9);
        AbESheet = writeAbsElevationsToExcel(test3, AbESheet, 14);
        AbESheet = writeAbsElevationsToExcel(test4, AbESheet, 19);

        //           

    }
    {

        ESheet = writeElevationsToExcel(pControl, ESheet, 0);
        ESheet = writeElevationsToExcel(test1, ESheet, 4);
        ESheet = writeElevationsToExcel(test2, ESheet, 9);
        ESheet = writeElevationsToExcel(test3, ESheet, 14);
        ESheet = writeElevationsToExcel(test4, ESheet, 19);
        Set<Double> Eset2 = new HashSet();
        Eset2.add(pControl.dev.meanElevation);
        Eset2.add(test1.dev.meanElevation);
        Eset2.add(test2.dev.meanElevation);
        Eset2.add(test3.dev.meanElevation);
        Eset2.add(test4.dev.meanElevation);
        Set<Double> Eset3 = new HashSet();
        Eset3.add(pControl.dev.verticalStandardDeviation);
        Eset3.add(test1.dev.verticalStandardDeviation);
        Eset3.add(test2.dev.verticalStandardDeviation);
        Eset3.add(test3.dev.verticalStandardDeviation);
        Eset3.add(test4.dev.verticalStandardDeviation);

        Row erow21 = ESheet.createRow((short) 24);
        Row erow22 = ESheet.createRow((short) 25);
        Row erow23 = ESheet.createRow((short) 27);
        Row erow24 = ESheet.createRow((short) 28);

        Cell erow21c = erow21.createCell(0);
        erow21c.setCellValue("Means");
        Cell erow22c = erow22.createCell(0);
        erow22c.setCellValue("Height");

        Cell erow23c = erow23.createCell(0);
        erow23c.setCellValue("Standard Deviations");
        Cell erow24c = erow24.createCell(0);
        erow24c.setCellValue("Height");

        int i = 1;
        for (Double d : Eset2) {
            erow22c = erow22.createCell(i);
            erow22c.setCellValue(d);
            i++;
        }
        i = 1;
        for (Double d : Eset3) {
            erow24c = erow24.createCell(i);
            erow24c.setCellValue(d);
            i++;
        }

    }

    {
        PSheet = writePositionsToExcel(pControl, PSheet, 0);
        PSheet = writePositionsToExcel(test1, PSheet, 4);
        PSheet = writePositionsToExcel(test2, PSheet, 9);
        PSheet = writePositionsToExcel(test3, PSheet, 14);
        PSheet = writePositionsToExcel(test4, PSheet, 19);
        {
            Set<Coordinate> set = new HashSet();
            set.add(pControl.dev.center);
            set.add(test1.dev.center);
            set.add(test2.dev.center);
            set.add(test3.dev.center);
            set.add(test4.dev.center);
            Set<Double> set2 = new HashSet();
            set2.add(pControl.dev.latitudeStandardDeviation);
            set2.add(test1.dev.latitudeStandardDeviation);
            set2.add(test2.dev.latitudeStandardDeviation);
            set2.add(test3.dev.latitudeStandardDeviation);
            set2.add(test4.dev.latitudeStandardDeviation);
            Set<Double> set3 = new HashSet();
            set3.add(pControl.dev.longitudeStandardDeviation);
            set3.add(test1.dev.longitudeStandardDeviation);
            set3.add(test2.dev.longitudeStandardDeviation);
            set3.add(test3.dev.longitudeStandardDeviation);
            set3.add(test4.dev.longitudeStandardDeviation);

            Row centerrow1 = PSheet.createRow((short) 24);
            Row centerrow2 = PSheet.createRow((short) 25);
            Row centerrow3 = PSheet.createRow((short) 26);
            Cell centerrow1c = centerrow1.createCell(0);
            centerrow1c.setCellValue("Centers");
            Cell centerrow2c = centerrow2.createCell(0);
            centerrow2c.setCellValue("lat");
            Cell row3c = centerrow3.createCell(0);
            row3c.setCellValue("long");

            int i = 1;
            for (Coordinate c : set) {
                centerrow1c = centerrow1.createCell(i);
                centerrow2c = centerrow2.createCell(i);
                centerrow1c.setCellValue(c.getLatitude());
                centerrow2c.setCellValue(-c.getLongitude());
                i++;

            }
        }
    }
    wb.write(fileOut);
    fileOut.close();
}

From source file:com.NRC.NMEA.main.NMEA.java

public static Sheet writeStatInfoToExcel(Sheet sheet) throws IOException {

    Queue<TestMap> q = new LinkedList();
    q.add(pControl);//from   w  w  w  . j av  a 2s.  c  om
    q.add(test1);
    q.add(test2);
    q.add(test3);
    q.add(test4);

    Row row0 = sheet.createRow((short) 0);

    row0.createCell(1).setCellValue("Mean Latitude");
    row0.createCell(2).setCellValue("Latitude Deviation");
    row0.createCell(3).setCellValue("Mean Longitude");
    row0.createCell(4).setCellValue("Longitude Deviation");
    row0.createCell(5).setCellValue("Mean Altitude");
    row0.createCell(6).setCellValue("Atitude Deviation");
    row0.createCell(7).setCellValue("Position Test Size");
    row0.createCell(8).setCellValue("Elevation Test Size");
    Row row;
    int i = 1;
    for (TestMap t : q) {
        row = sheet.createRow((short) i);

        row.createCell(0).setCellValue(t.name);
        row.createCell(1).setCellValue(t.dev.center.getLatitude());
        row.createCell(2).setCellValue(t.dev.latitudeStandardDeviation);
        row.createCell(3).setCellValue(-t.dev.center.getLongitude());
        row.createCell(4).setCellValue(t.dev.longitudeStandardDeviation);
        row.createCell(5).setCellValue(t.dev.meanElevation);
        row.createCell(6).setCellValue(t.dev.verticalStandardDeviation);
        row.createCell(7).setCellValue(t.dev.PosTestSize);
        row.createCell(8).setCellValue(t.dev.ETestSize);
        i++;
    }
    return sheet;
}

From source file:com.NRC.NMEA.main.NMEA.java

public static Sheet writeElevationsToExcel(TestMap m, Sheet sheet, int startRow) throws IOException {
    PseudoCollectionSet s = new PseudoCollectionSet();

    for (DataPointInTime d : m) {
        Double f = (d.elevation);
        if (!(f == 0.0)) {
            s.add(f);//  w  ww . j  a v a2s .c o  m
        }
    }
    Row row1 = sheet.createRow((short) startRow);
    Row row2 = sheet.createRow((short) startRow + 1);
    Row row3 = sheet.createRow((short) startRow + 2);
    Cell row1c = row1.createCell(0);
    row1c.setCellValue(m.name);
    Cell row2c = row2.createCell(0);
    row2c.setCellValue("Elevation");
    Cell row3c = row3.createCell(0);
    row3c.setCellValue("Multiples");
    int coli = 1;
    for (Object c : s) {
        row2c = row2.createCell(coli);
        row2c.setCellValue((Double) c);
        row3c = row3.createCell(coli);
        row3c.setCellValue(s.getMultiples(c));
        coli++;
    }
    return sheet;
}