Example usage for org.apache.poi.xssf.usermodel XSSFCell setCellValue

List of usage examples for org.apache.poi.xssf.usermodel XSSFCell setCellValue

Introduction

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

Prototype

@Override
public void setCellValue(boolean value) 

Source Link

Document

Set a boolean value for the cell

Usage

From source file:es.upm.oeg.tools.rdfshapes.patterns.DatatypeObjectPropertyPatterns.java

License:Apache License

public static void main(String[] args) throws Exception {

    String endpoint = "http://3cixty.eurecom.fr/sparql";

    List<String> classList = Files.readAllLines(Paths.get(classListPath), Charset.defaultCharset());

    String classPropertyQueryString = readFile(classPropertyQueryPath, Charset.defaultCharset());
    String propertyCardinalityQueryString = readFile(propertyCardinalityQueryPath, Charset.defaultCharset());
    String individualCountQueryString = readFile(individualCountQueryPath, Charset.defaultCharset());
    String objectCountQueryString = readFile(objectCountQueryPath, Charset.defaultCharset());
    String tripleCountQueryString = readFile(tripleCountQueryPath, Charset.defaultCharset());
    String literalCountQueryString = readFile(literalCountQueryPath, Charset.defaultCharset());
    String blankCountQueryString = readFile(blankCountQueryPath, Charset.defaultCharset());
    String iriCountQueryString = readFile(iriCountQueryPath, Charset.defaultCharset());
    String datatypeCountQueryString = readFile(datatypeCountsPath, Charset.defaultCharset());

    DecimalFormat df = new DecimalFormat("0.0000");

    //Create the Excel workbook and sheet
    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sheet = wb.createSheet("Cardinality");

    int currentExcelRow = 0;
    int classStartRow = 0;

    for (String clazz : classList) {

        System.out.println("Class: " + clazz);

        Map<String, String> litMap = new HashMap<>();
        Map<String, String> iriMap = ImmutableMap.of("class", clazz);

        String queryString = bindQueryString(individualCountQueryString,
                ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));

        int individualCount;
        List<RDFNode> c = executeQueryForList(queryString, endpoint, "c");
        if (c.size() == 1) {
            individualCount = c.get(0).asLiteral().getInt();
        } else {//from w  w w  . j  av  a2  s .co  m
            continue;
        }

        // If there are zero individuals, continue
        if (individualCount == 0) {
            throw new IllegalStateException("Check whether " + classListPath + " and " + endpoint + " match.");
        }

        classStartRow = currentExcelRow;
        XSSFRow row = sheet.createRow(currentExcelRow);
        XSSFCell cell = row.createCell(0);
        cell.setCellValue(clazz);

        litMap = new HashMap<>();
        iriMap = ImmutableMap.of("class", clazz);
        queryString = bindQueryString(classPropertyQueryString,
                ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));
        List<RDFNode> nodeList = executeQueryForList(queryString, endpoint, "p");

        //            System.out.println("***");
        //            System.out.println("### **" + clazz + "**");
        //            System.out.println("***");
        //            System.out.println();

        cell.getCellStyle().setAlignment(CellStyle.ALIGN_CENTER);

        for (RDFNode property : nodeList) {
            if (property.isURIResource()) {

                System.out.println("          " + property);

                int tripleCount;
                int objectCount;
                int literalCount;
                int blankCount;
                int iriCount;

                String propertyURI = property.asResource().getURI();

                XSSFRow propertyRow = sheet.getRow(currentExcelRow);
                if (propertyRow == null) {
                    propertyRow = sheet.createRow(currentExcelRow);
                }
                currentExcelRow++;
                XSSFCell propertyCell = propertyRow.createCell(1);
                propertyCell.setCellValue(propertyURI);

                litMap = new HashMap<>();
                iriMap = ImmutableMap.of("class", clazz, "p", propertyURI);

                queryString = bindQueryString(tripleCountQueryString,
                        ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));

                c = executeQueryForList(queryString, endpoint, "c");
                if (c.size() > 0) {
                    tripleCount = c.get(0).asLiteral().getInt();
                } else {
                    tripleCount = 0;
                }

                queryString = bindQueryString(objectCountQueryString,
                        ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));

                c = executeQueryForList(queryString, endpoint, "c");
                if (c.size() > 0) {
                    objectCount = c.get(0).asLiteral().getInt();
                } else {
                    objectCount = 0;
                }

                queryString = bindQueryString(literalCountQueryString,
                        ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));
                c = executeQueryForList(queryString, endpoint, "c");
                if (c.size() > 0) {
                    literalCount = c.get(0).asLiteral().getInt();
                } else {
                    literalCount = 0;
                }

                queryString = bindQueryString(blankCountQueryString,
                        ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));
                c = executeQueryForList(queryString, endpoint, "c");
                if (c.size() > 0) {
                    blankCount = c.get(0).asLiteral().getInt();
                } else {
                    blankCount = 0;
                }

                queryString = bindQueryString(iriCountQueryString,
                        ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));
                c = executeQueryForList(queryString, endpoint, "c");
                if (c.size() > 0) {
                    iriCount = c.get(0).asLiteral().getInt();
                } else {
                    iriCount = 0;
                }

                XSSFCell objectCountCell = propertyRow.createCell(2);
                objectCountCell.setCellValue(objectCount);

                XSSFCell uniqueObjectsCell = propertyRow.createCell(3);
                uniqueObjectsCell.setCellValue(df.format(((double) objectCount) / tripleCount));

                XSSFCell literalCell = propertyRow.createCell(4);
                literalCell.setCellValue(df.format((((double) literalCount) / objectCount)));

                XSSFCell iriCell = propertyRow.createCell(5);
                iriCell.setCellValue(df.format((((double) iriCount) / objectCount)));

                XSSFCell blankCell = propertyRow.createCell(6);
                blankCell.setCellValue(df.format((((double) blankCount) / objectCount)));

                if (literalCount > 0) {

                    litMap = new HashMap<>();
                    iriMap = ImmutableMap.of("class", clazz, "p", propertyURI);

                    queryString = bindQueryString(datatypeCountQueryString,
                            ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));
                    List<Map<String, RDFNode>> solnMaps = executeQueryForList(queryString, endpoint,
                            ImmutableSet.of("datatype", "c"));

                    int i = 1;
                    for (Map<String, RDFNode> soln : solnMaps) {
                        String datatype = soln.get("datatype").asResource().getURI();
                        int count = soln.get("c").asLiteral().getInt();

                        XSSFCell dataCell = propertyRow.createCell(6 + i++);
                        dataCell.setCellValue(datatype);

                        dataCell = propertyRow.createCell(6 + i++);
                        dataCell.setCellValue(df.format((((double) count) / objectCount)));

                    }

                }

                //                    System.out.println("* " + propertyURI);
                //                    System.out.println();
                //
                //                    System.out.println("| Object Count | Unique Objects | Literals | IRIs | Blank Nodes | ");
                //                    System.out.println("|---|---|---|---|---|");
                //                    System.out.println(String.format("|%d|%d (%.2f%%) |%d (%.2f%%)|%d (%.2f%%)|%d (%.2f%%)|",
                //                            tripleCount,
                //                            objectCount, ((((double) objectCount)/tripleCount)*100),
                //                            literalCount, ((((double) literalCount)/objectCount)*100),
                //                            iriCount, ((((double) iriCount)/objectCount)*100),
                //                            blankCount, ((((double) blankCount)/objectCount)*100)));
                //                    System.out.println();
            }
        }
    }

    String filename = "literals.xls";
    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();

}

From source file:es.upm.oeg.tools.rdfshapes.utils.CadinalityResultGenerator.java

License:Apache License

public static void main(String[] args) throws Exception {

    String endpoint = "http://3cixty.eurecom.fr/sparql";

    List<String> classList = Files.readAllLines(Paths.get(classListPath), Charset.defaultCharset());

    String classPropertyQueryString = readFile(classPropertyQueryPath, Charset.defaultCharset());
    String propertyCardinalityQueryString = readFile(propertyCardinalityQueryPath, Charset.defaultCharset());
    String individualCountQueryString = readFile(individualCountQueryPath, Charset.defaultCharset());

    DecimalFormat df = new DecimalFormat("0.0000");

    //Create the Excel workbook and sheet
    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sheet = wb.createSheet("Cardinality");

    int currentExcelRow = 0;
    int classStartRow = 0;

    for (String clazz : classList) {

        Map<String, String> litMap = new HashMap<>();
        Map<String, String> iriMap = ImmutableMap.of("class", clazz);

        String queryString = bindQueryString(individualCountQueryString,
                ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));

        int individualCount;
        List<RDFNode> c = executeQueryForList(queryString, endpoint, "c");
        if (c.size() == 1) {
            individualCount = c.get(0).asLiteral().getInt();
        } else {/*from  w w  w  .  j  ava 2  s . c  om*/
            continue;
        }

        // If there are zero individuals, continue
        if (individualCount == 0) {
            throw new IllegalStateException("Check whether " + classListPath + " and " + endpoint + " match.");
        }

        //            System.out.println("***");
        //            System.out.println("### **" + clazz + "** (" + individualCount + ")");
        //            System.out.println("***");
        //            System.out.println();

        classStartRow = currentExcelRow;
        XSSFRow row = sheet.createRow(currentExcelRow);
        XSSFCell cell = row.createCell(0);
        cell.setCellValue(clazz);
        cell.getCellStyle().setAlignment(CellStyle.ALIGN_CENTER);

        queryString = bindQueryString(classPropertyQueryString,
                ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));

        List<RDFNode> nodeList = executeQueryForList(queryString, endpoint, "p");

        for (RDFNode property : nodeList) {
            if (property.isURIResource()) {

                DescriptiveStatistics stats = new DescriptiveStatistics();

                String propertyURI = property.asResource().getURI();
                //                    System.out.println("* " + propertyURI);
                //                    System.out.println();

                XSSFRow propertyRow = sheet.getRow(currentExcelRow);
                if (propertyRow == null) {
                    propertyRow = sheet.createRow(currentExcelRow);
                }
                currentExcelRow++;

                XSSFCell propertyCell = propertyRow.createCell(1);
                propertyCell.setCellValue(propertyURI);

                Map<String, String> litMap2 = new HashMap<>();
                Map<String, String> iriMap2 = ImmutableMap.of("class", clazz, "p", propertyURI);

                queryString = bindQueryString(propertyCardinalityQueryString,
                        ImmutableMap.of(IRI_BINDINGS, iriMap2, LITERAL_BINDINGS, litMap2));

                List<Map<String, RDFNode>> solnMaps = executeQueryForList(queryString, endpoint,
                        ImmutableSet.of("card", "count"));

                int sum = 0;
                List<CardinalityCount> cardinalityList = new ArrayList<>();
                if (solnMaps.size() > 0) {

                    for (Map<String, RDFNode> soln : solnMaps) {
                        int count = soln.get("count").asLiteral().getInt();
                        int card = soln.get("card").asLiteral().getInt();

                        for (int i = 0; i < count; i++) {
                            stats.addValue(card);
                        }

                        CardinalityCount cardinalityCount = new CardinalityCount(card, count,
                                (((double) count) / individualCount) * 100);
                        cardinalityList.add(cardinalityCount);
                        sum += count;
                    }

                    // Check for zero cardinality instances
                    int count = individualCount - sum;
                    if (count > 0) {
                        for (int i = 0; i < count; i++) {
                            stats.addValue(0);
                        }
                        CardinalityCount cardinalityCount = new CardinalityCount(0, count,
                                (((double) count) / individualCount) * 100);
                        cardinalityList.add(cardinalityCount);
                    }
                }

                Map<Integer, Double> cardMap = new HashMap<>();
                for (CardinalityCount count : cardinalityList) {
                    cardMap.put(count.getCardinality(), count.getPrecentage());
                }

                XSSFCell instanceCountCell = propertyRow.createCell(2);
                instanceCountCell.setCellValue(individualCount);

                XSSFCell minCell = propertyRow.createCell(3);
                minCell.setCellValue(stats.getMin());

                XSSFCell maxCell = propertyRow.createCell(4);
                maxCell.setCellValue(stats.getMax());

                XSSFCell p1 = propertyRow.createCell(5);
                p1.setCellValue(stats.getPercentile(1));

                XSSFCell p99 = propertyRow.createCell(6);
                p99.setCellValue(stats.getPercentile(99));

                XSSFCell mean = propertyRow.createCell(7);
                mean.setCellValue(df.format(stats.getMean()));

                for (int i = 0; i < 21; i++) {
                    XSSFCell dataCell = propertyRow.createCell(8 + i);
                    Double percentage = cardMap.get(i);
                    if (percentage != null) {
                        dataCell.setCellValue(df.format(percentage));
                    } else {
                        dataCell.setCellValue(0);
                    }
                }

                //                    System.out.println("| Min Card. |Max Card. |");
                //                    System.out.println("|---|---|");
                //                    System.out.println("| ? | ? |");
                //                    System.out.println();

            }
        }

        //System.out.println("class start: " + classStartRow + ", class end: " + (currentExcelRow -1));
        //We have finished writting properties of one class, now it's time to merge the cells
        int classEndRow = currentExcelRow - 1;
        if (classStartRow < classEndRow) {
            sheet.addMergedRegion(new CellRangeAddress(classStartRow, classEndRow, 0, 0));
        }

    }

    String filename = "3cixty.xls";
    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();
}

From source file:es.upm.oeg.tools.rdfshapes.utils.CardinalityTemplateGenerator.java

License:Apache License

public static void main(String[] args) throws Exception {

    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF,
            ModelFactory.createDefaultModel());
    model.read("http://dublincore.org/2012/06/14/dcelements.ttl");

    String endpoint = "http://infra2.dia.fi.upm.es:8899/sparql";

    List<String> classList = Files.readAllLines(Paths.get(classListPath), Charset.defaultCharset());

    String classPropertyQueryString = readFile(classPropertyQueryPath, Charset.defaultCharset());
    String propertyCardinalityQueryString = readFile(propertyCardinalityQueryPath, Charset.defaultCharset());
    String individualCountQueryString = readFile(individualCountQueryPath, Charset.defaultCharset());

    //Create the Excel workbook and sheet
    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sheet = wb.createSheet("Cardinality");

    int currentExcelRow = 0;
    int classStartRow = 0;

    for (String clazz : classList) {

        Map<String, String> litMap = new HashMap<>();
        Map<String, String> iriMap = ImmutableMap.of("class", clazz);

        String queryString = bindQueryString(individualCountQueryString,
                ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));

        int individualCount;
        List<RDFNode> c = executeQueryForList(queryString, endpoint, "c");
        if (c.size() == 1) {
            individualCount = c.get(0).asLiteral().getInt();
        } else {/*from  w w  w.  j av  a  2s .com*/
            continue;
        }

        // If there are zero individuals, continue
        if (individualCount == 0) {
            throw new IllegalStateException("Check whether " + classListPath + " and " + endpoint + " match.");
        }

        //            System.out.println("***");
        //            System.out.println("### **" + clazz + "** (" + individualCount + ")");
        //            System.out.println("***");
        //            System.out.println();

        classStartRow = currentExcelRow;
        XSSFRow row = sheet.createRow(currentExcelRow);
        XSSFCell cell = row.createCell(0);
        cell.setCellValue(clazz);
        cell.getCellStyle().setAlignment(CellStyle.ALIGN_CENTER);

        queryString = bindQueryString(classPropertyQueryString,
                ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));

        List<RDFNode> nodeList = executeQueryForList(queryString, endpoint, "p");

        for (RDFNode property : nodeList) {
            if (property.isURIResource()) {

                String propertyURI = property.asResource().getURI();
                //                    System.out.println("* " + propertyURI);
                //                    System.out.println();

                XSSFRow propertyRow = sheet.getRow(currentExcelRow);
                if (propertyRow == null) {
                    propertyRow = sheet.createRow(currentExcelRow);
                }
                currentExcelRow++;

                XSSFCell propertyCell = propertyRow.createCell(1);
                propertyCell.setCellValue(propertyURI);

                //                    System.out.println("| Min Card. |Max Card. |");
                //                    System.out.println("|---|---|");
                //                    System.out.println("| ? | ? |");
                //                    System.out.println();

            }
        }

        //System.out.println("class start: " + classStartRow + ", class end: " + (currentExcelRow -1));
        //We have finished writting properties of one class, now it's time to merge the cells
        int classEndRow = currentExcelRow - 1;
        if (classStartRow < classEndRow) {
            sheet.addMergedRegion(new CellRangeAddress(classStartRow, classEndRow, 0, 0));
        }

    }

    String filename = "test.xls";
    FileOutputStream fileOut = new FileOutputStream(filename);
    wb.write(fileOut);
    fileOut.close();

}

From source file:gov.anl.cue.arcane.engine.matrix.MatrixEngine.java

License:Open Source License

/**
 * Creates the row header.//ww  w.  java2 s.  com
 *
 * @param workbook the workbook
 * @param sheet the sheet
 * @param rowIndex the row index
 * @param label1 the label1
 * @param label2 the label2
 */
public void createRowHeader(XSSFWorkbook workbook, XSSFSheet sheet, int rowIndex, String label1,
        String label2) {

    // Create the needed highlight style.
    XSSFCellStyle cellStyle = workbook.createCellStyle();
    cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(197, 217, 241)));
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    XSSFFont font = workbook.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    cellStyle.setFont(font);

    // Create the requested row.
    XSSFRow row = sheet.createRow(0);
    XSSFCell cell = row.createCell(0);
    cell.setCellValue(label1);
    cell.setCellStyle(cellStyle);
    cell = row.createCell(1);
    cell.setCellValue(label2);
    cell.setCellStyle(cellStyle);

}

From source file:gov.anl.cue.arcane.engine.matrix.MatrixEngine.java

License:Open Source License

/**
 * Creates the row int./*from  www  .  jav a  2s  . c o  m*/
 *
 * @param sheet the sheet
 * @param rowIndex the row index
 * @param label the label
 * @param value the value
 */
public void createRowInt(XSSFSheet sheet, int rowIndex, String label, int value) {

    // Create the requested row.
    XSSFRow row = sheet.createRow(rowIndex);
    XSSFCell cell = row.createCell(0);
    cell.setCellValue(label);
    cell = row.createCell(1);
    cell.setCellValue(value);

}

From source file:gov.anl.cue.arcane.engine.matrix.MatrixEngine.java

License:Open Source License

/**
 * Creates the row double.//from   w  w w  .  j a  v  a2 s . c  om
 *
 * @param sheet the sheet
 * @param rowIndex the row index
 * @param label the label
 * @param value the value
 */
public void createRowDouble(XSSFSheet sheet, int rowIndex, String label, double value) {

    // Create the requested row.
    XSSFRow row = sheet.createRow(rowIndex);
    XSSFCell cell = row.createCell(0);
    cell.setCellValue(label);
    cell = row.createCell(1);
    cell.setCellValue(value);

}

From source file:gov.anl.cue.arcane.engine.matrix.MatrixModel.java

License:Open Source License

/**
 * Write scan variables.// w  w  w .  j a v a2s  .c om
 *
 * @param workbook the workbook
 * @param cellStyle the cell style
 * @throws OutOfRangeException the out of range exception
 */
public void writeScanVariables(XSSFWorkbook workbook, XSSFCellStyle cellStyle) throws OutOfRangeException {

    // Scan the variables.
    for (MatrixVariable matrixVariable : this) {

        // Fill in a header.
        XSSFSheet sheet = workbook
                .createSheet(matrixVariable.name + " (" + matrixVariable.units.getUnit() + ")");
        XSSFRow row = sheet.createRow(0);
        XSSFCell cell = row.createCell(0);
        cell.setCellValue("Equation");
        cell.setCellStyle(cellStyle);
        cell = row.createCell(1);
        cell.setCellValue("Node");
        cell.setCellStyle(cellStyle);
        for (int rowIndex = 0; rowIndex < matrixVariable.equations.size(); rowIndex++) {
            cell = row.createCell(rowIndex + 2);
            cell.setCellValue(this.nodeName(rowIndex));
            cell.setCellStyle(cellStyle);
        }

        // Fill in the main rows.
        for (int rowIndex = 0; rowIndex < matrixVariable.equations.size(); rowIndex++) {

            // Create the next row.
            row = sheet.createRow(rowIndex + 1);

            // Create the equation column.
            cell = row.createCell(0);
            cell.setCellValue(matrixVariable.equations.get(rowIndex));

            // Create the node index column.
            cell = row.createCell(1);
            cell.setCellValue(this.nodeName(rowIndex));
            cell.setCellStyle(cellStyle);

            // Fill in the coefficients.
            for (int columnIndex = 0; columnIndex < matrixVariable.equations.size(); columnIndex++) {
                cell = row.createCell(columnIndex + 2);
                double cellValue = matrixVariable.coefficients.getEntry(rowIndex, columnIndex);
                if (!Double.isNaN(cellValue)) {
                    cell.setCellValue(cellValue);
                }
            }

        }

    }

}

From source file:gov.anl.cue.arcane.engine.matrix.MatrixModel.java

License:Open Source License

/**
 * Write fitness function information./*from   w ww.  j  av a  2 s  .  co m*/
 *
 * @param workbook the workbook
 * @param cellStyle the cell style
 * @return the XSSF sheet
 */
public XSSFSheet writeFitnessFunctionInformation(XSSFWorkbook workbook, XSSFCellStyle cellStyle) {

    // Fill in the fitness header.
    XSSFSheet sheet = workbook.createSheet("Fitness");
    XSSFRow row = sheet.createRow(0);
    XSSFCell cell = row.createCell(0);
    cell.setCellValue("Equation");
    cell.setCellStyle(cellStyle);
    cell = row.createCell(1);
    cell.setCellValue("Node");
    cell.setCellStyle(cellStyle);

    // Fill in the fitness equations.
    for (int rowIndex = 0; rowIndex < fitnessEquations.size(); rowIndex++) {

        // Create the next row.
        row = sheet.createRow(rowIndex + 1);

        // Create the equation column.
        cell = row.createCell(0);
        cell.setCellValue(this.fitnessEquations.get(rowIndex));

        // Create the node index column.
        cell = row.createCell(1);
        cell.setCellValue(this.nodeName(rowIndex));
        cell.setCellStyle(cellStyle);

    }

    // Fill in the fitness value footer.
    row = sheet.createRow(fitnessEquations.size() + 1);
    cell = row.createCell(0);
    if (this.fitnessFunctionType == MatrixModel.FITNESS_FUNCTION_TYPE.SIMPLE_MAXIMUM) {
        cell.setCellValue(MatrixModel.SIMPLE_MAXIMUM_STRING);
    } else if (this.fitnessFunctionType == MatrixModel.FITNESS_FUNCTION_TYPE.USER_EQUATION) {
        cell.setCellValue(MatrixModel.SYSTEM_DYNAMICS_STRING);
    } else {
        cell.setCellValue(MatrixModel.ZERO_FITNESS_STRING);
    }
    cell = row.createCell(1);
    if (!Double.isNaN(this.getFitnessValue())) {
        cell.setCellValue(this.getFitnessValue());
    }

    // Fill in the step count and size.
    if (this.fitnessFunctionType == MatrixModel.FITNESS_FUNCTION_TYPE.USER_EQUATION) {
        row = sheet.createRow(fitnessEquations.size() + 2);
        cell = row.createCell(0);
        cell.setCellValue(MatrixModel.SYSTEM_DYNAMICS_STEP_COUNT_STRING);
        cell = row.createCell(1);
        cell.setCellValue(this.stepCount);
        row = sheet.createRow(fitnessEquations.size() + 3);
        cell = row.createCell(0);
        cell.setCellValue(MatrixModel.SYSTEM_DYNAMICS_STEP_SIZE_STRING);
        cell = row.createCell(1);
        cell.setCellValue(this.stepSize);
        row = sheet.createRow(fitnessEquations.size() + 4);
        cell = row.createCell(0);
        cell.setCellValue(MatrixModel.SYSTEM_DYNAMICS_GROW_STRING);
        cell = row.createCell(1);
        if (this.equationEvolution) {
            cell.setCellValue("Yes");
        } else {
            cell.setCellValue("No");
        }

    }

    // Return the results.
    return sheet;

}

From source file:hangargame.xml.AfficherListGamerAdminController.java

@FXML
void ExtraireExcel(ActionEvent event) throws FileNotFoundException, IOException {
    List<Gamer> l = new ArrayList();
    l = s.AfficherListeGamer();/* ww  w  . j  a v  a 2  s .com*/
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet spreadsheet = workbook.createSheet("Hangar Game");
    XSSFRow row = spreadsheet.createRow(1);
    XSSFCell cell;
    cell = row.createCell(1);
    cell.setCellValue("Login");
    cell = row.createCell(2);
    cell.setCellValue("Nom");
    cell = row.createCell(3);
    cell.setCellValue("Prenom");
    cell = row.createCell(4);
    cell.setCellValue("E-mail");
    cell = row.createCell(5);
    cell.setCellValue("Adresse");
    cell = row.createCell(6);
    cell.setCellValue("Tlphone");
    cell = row.createCell(7);
    cell.setCellValue("Data d'inscription");
    cell = row.createCell(8);
    cell.setCellValue("Etat");
    for (int i = 1; i < l.size() - 1; i++) {
        row = spreadsheet.createRow(i);
        cell = row.createCell(1);
        cell.setCellValue(l.get(i).getLogin());
        cell = row.createCell(2);
        cell.setCellValue(l.get(i).getNom());
        cell = row.createCell(3);
        cell.setCellValue(l.get(i).getPrenom());
        cell = row.createCell(4);
        cell.setCellValue(l.get(i).getEmail());
        cell = row.createCell(5);
        cell.setCellValue(l.get(i).getAdresse());
        cell = row.createCell(6);
        cell.setCellValue(l.get(i).getTel());
        cell = row.createCell(7);
        cell.setCellValue(l.get(i).getDateInscription());
        cell = row.createCell(8);
        cell.setCellValue(l.get(i).getEtat());

    }
    FileOutputStream out = new FileOutputStream(new File("exceldatabase.xlsx"));
    workbook.write(out);
    out.close();
    tray.notification.TrayNotification tr = new TrayNotification();
    tr.setTitle("Extraction faite avec succes");
    tr.setMessage("Tlechargement sous Document/netbeans/hangargame ");
    tr.setNotificationType(NotificationType.SUCCESS);
    tr.setAnimationType(AnimationType.SLIDE);
    tr.showAndDismiss(Duration.seconds(5));
}

From source file:ik1004labb5.DAOHundExcel.java

@Override
public void add(DTOHund dtoHund) {
    XSSFWorkbook workbook = getExcelWorkbook();
    XSSFSheet worksheet = workbook.getSheetAt(0);
    //G ner i hierarkun frn workbook, till sheet row osv.
    XSSFRow row = worksheet.createRow(worksheet.getLastRowNum() + 1);
    XSSFCell id = row.createCell(0); //skapa celler fr varje "instans", namn, ras osv.
    XSSFCell namn = row.createCell(1);/*  ww w  .j a v a2s  .co  m*/
    XSSFCell ras = row.createCell(2);
    XSSFCell bildURL = row.createCell(3);
    //XSSFCell iHundgrd = row.createCell(4);

    id.setCellValue(Integer.toString(dtoHund.getId()));
    namn.setCellValue(dtoHund.getNamn());
    ras.setCellValue(dtoHund.getRas());
    bildURL.setCellValue(dtoHund.getBildURL());
    //iHundgrd.setCellValue(dtoHund.isiHundgrd().get());
    //worksheet.createRow(worksheet.getLastRowNum() + 1);    FRBANNELSENS RAD! Visa Elin.

    saveToExcel(workbook);
}