Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Row$MissingCellPolicy


           }

           public ColumnImpl expectValues(Number... expectedNumbers) {
               evaluateCellValues();

               Row row = sheet.getRow(rowNo);
               for (int i = 0; i < expectedNumbers.length; ++i) {
                   String cellName = String.format("col:%s,row:%s", i+1, rowNo+1);
                   Cell cell = row.getCell(column+i);

                   //getStringCellValue, getNumericCellValue, getErrorCellValue
                   //XSFFCell.CELL_TYPE_STRING,XSFFCell.CELL_TYPE_NUMERIC,XSFFCell.CELL_TYPE_ERROR
    //                   assertThat(cell.getErrorCellValue()).isEqualTo((byte)3);
                   checkNotNull(expectedNumbers[i]);
View Full Code Here


     */
    @Test
    public void bug47490() throws Exception {
       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx");
       Sheet s = wb.getSheetAt(1);
       Row r;
       DataFormatter df = new DataFormatter();
      
       r = s.getRow(1);
       assertEquals(1.0, r.getCell(2).getNumericCellValue(), 0);
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("1", df.formatCellValue(r.getCell(2)));
       assertEquals("1", df.formatRawCellContents(1.0, -1, "@"));
       assertEquals("1", df.formatRawCellContents(1.0, -1, "General"));
             
       r = s.getRow(2);
       assertEquals(12.0, r.getCell(2).getNumericCellValue(), 0);
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("12", df.formatCellValue(r.getCell(2)));
       assertEquals("12", df.formatRawCellContents(12.0, -1, "@"));
       assertEquals("12", df.formatRawCellContents(12.0, -1, "General"));
      
       r = s.getRow(3);
       assertEquals(123.0, r.getCell(2).getNumericCellValue(), 0);
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("123", df.formatCellValue(r.getCell(2)));
       assertEquals("123", df.formatRawCellContents(123.0, -1, "@"));
       assertEquals("123", df.formatRawCellContents(123.0, -1, "General"));
    }
View Full Code Here

             new HSSFWorkbook(),
             new XSSFWorkbook()
       };
       for(Workbook wb : wbs) {
          Sheet s = wb.createSheet();
          Row r = s.createRow(0);
         
          // Setup
          Cell cn = r.createCell(0, Cell.CELL_TYPE_NUMERIC);
          cn.setCellValue(1.2);
          Cell cs = r.createCell(1, Cell.CELL_TYPE_STRING);
          cs.setCellValue("Testing");
         
          Cell cfn = r.createCell(2, Cell.CELL_TYPE_FORMULA);
          cfn.setCellFormula("A1")
          Cell cfs = r.createCell(3, Cell.CELL_TYPE_FORMULA);
          cfs.setCellFormula("B1");
         
          FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
          assertEquals(Cell.CELL_TYPE_NUMERIC, fe.evaluate(cfn).getCellType());
          assertEquals(Cell.CELL_TYPE_STRING, fe.evaluate(cfs).getCellType());
View Full Code Here

        Sheet sheet = wb.getSheetAt(0);


        // go through all formula cells
        for (int rInd = 2; rInd <= rowMax; rInd++) {
            Row row = sheet.getRow(rInd);

            for (int cInd = 1; cInd <= 12; cInd++) {
                Cell cell = row.getCell(cInd);
                String formula = cell.getCellFormula();
                CellReference ref = new CellReference(cell);

                //simulate correct answer
                String correct = "$A" + (rInd + 1) + "*" + columns[cInd] + "$2";
View Full Code Here

     */
    @Test
    public void bug54034() throws IOException {
        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("54034.xlsx");
        Sheet sheet = wb.getSheet("Sheet1");
        Row row = sheet.getRow(1);
        Cell cell = row.getCell(2);
        assertTrue(DateUtil.isCellDateFormatted(cell));
       
        DataFormatter fmt = new DataFormatter();
        assertEquals("yyyy\\-mm\\-dd\\Thh:mm", cell.getCellStyle().getDataFormatString());
        assertEquals("2012-08-08T22:59", fmt.formatCellValue(cell));
View Full Code Here

        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56420.xlsx");
       
        FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();

        Sheet sheet = wb.getSheetAt(0);
        Row r = sheet.getRow(2);
        Cell c = r.getCell(2);
        assertEquals("SUMIF($A$1:$A$4,A3,$B$1:$B$4)", c.getCellFormula());
        evaluator.evaluateInCell(c);
    }
View Full Code Here

        testSheet.shiftRows(2, 2, 1);

        saveAndReloadReport(wb, xlsOutput);

        Row newRow = null;
        Cell newCell = null;
        // 2) attempt to create a new row IN PLACE of a removed row by a negative shift causes corrupted
        // xlsx file with  unreadable data in the negative shifted row.
        // NOTE it's ok to create any other row.
        newRow = testSheet.createRow(3);

        saveAndReloadReport(wb, xlsOutput);

        newCell = newRow.createCell(0);

        saveAndReloadReport(wb, xlsOutput);

        newCell.setCellValue("new Cell in row "+newRow.getRowNum());

        saveAndReloadReport(wb, xlsOutput);

        // 3) once a negative shift has been made any attempt to shift another group of rows
        // (note: outside of previously negative shifted rows) by a POSITIVE amount causes POI exception:
View Full Code Here

    assertEquals(4, sheet.getNumHyperlinks());
    doTestHyperlinkContents(sheet);


    // Add one more, and re-check
    Row r17 = sheet.createRow(17);
    Cell r17c = r17.createCell(2);

    Hyperlink hyperlink = createHelper.createHyperlink(Hyperlink.LINK_URL);
    hyperlink.setAddress("http://poi.apache.org/spreadsheet/");
    hyperlink.setLabel("POI SS Link");
    r17c.setHyperlink(hyperlink);
View Full Code Here

     for integers
     */
    public void test47490() throws Exception {
       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx");
       Sheet s = wb.getSheetAt(1);
       Row r;
       DataFormatter df = new DataFormatter();
      
       r = s.getRow(1);
       assertEquals(1.0, r.getCell(2).getNumericCellValue());
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("1", df.formatCellValue(r.getCell(2)));
       assertEquals("1", df.formatRawCellContents(1.0, -1, "@"));
       assertEquals("1", df.formatRawCellContents(1.0, -1, "General"));
             
       r = s.getRow(2);
       assertEquals(12.0, r.getCell(2).getNumericCellValue());
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("12", df.formatCellValue(r.getCell(2)));
       assertEquals("12", df.formatRawCellContents(12.0, -1, "@"));
       assertEquals("12", df.formatRawCellContents(12.0, -1, "General"));
      
       r = s.getRow(3);
       assertEquals(123.0, r.getCell(2).getNumericCellValue());
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("123", df.formatCellValue(r.getCell(2)));
       assertEquals("123", df.formatRawCellContents(123.0, -1, "@"));
       assertEquals("123", df.formatRawCellContents(123.0, -1, "General"));
    }
View Full Code Here

             new HSSFWorkbook(),
             new XSSFWorkbook()
       };
       for(Workbook wb : wbs) {
          Sheet s = wb.createSheet();
          Row r = s.createRow(0);
         
          // Setup
          Cell cn = r.createCell(0, Cell.CELL_TYPE_NUMERIC);
          cn.setCellValue(1.2);
          Cell cs = r.createCell(1, Cell.CELL_TYPE_STRING);
          cs.setCellValue("Testing");
         
          Cell cfn = r.createCell(2, Cell.CELL_TYPE_FORMULA);
          cfn.setCellFormula("A1")
          Cell cfs = r.createCell(3, Cell.CELL_TYPE_FORMULA);
          cfs.setCellFormula("B1");
         
          FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
          assertEquals(Cell.CELL_TYPE_NUMERIC, fe.evaluate(cfn).getCellType());
          assertEquals(Cell.CELL_TYPE_STRING, fe.evaluate(cfs).getCellType());
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Row$MissingCellPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.