Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Name


     * Test for a file with NameRecord with NameCommentRecord comments
     */
    @Test
    public void bug49185() throws Exception {
      HSSFWorkbook wb = openSample("49185.xls");
      Name name = wb.getName("foobarName");
      assertEquals("This is a comment", name.getComment());
     
      // Rename the name, comment comes with it
      name.setNameName("ChangedName");
      assertEquals("This is a comment", name.getComment());
     
      // Save and re-check
      wb = writeOutAndReadBack(wb);
      name = wb.getName("ChangedName");
      assertEquals("This is a comment", name.getComment());
     
      // Now try to change it
      name.setComment("Changed Comment");
      assertEquals("Changed Comment", name.getComment());
     
      // Save and re-check
      wb = writeOutAndReadBack(wb);
      name = wb.getName("ChangedName");
      assertEquals("Changed Comment", name.getComment());
    }
View Full Code Here


    @Test
    public void bug56737() throws IOException {
        Workbook wb = openSample("56737.xls");
       
        // Check the named range definitions
        Name nSheetScope = wb.getName("NR_To_A1");
        Name nWBScope = wb.getName("NR_Global_B2");

        assertNotNull(nSheetScope);
        assertNotNull(nWBScope);
       
        assertEquals("Defines!$A$1", nSheetScope.getRefersToFormula());
        assertEquals("Defines!$B$2", nWBScope.getRefersToFormula());
       
        // Check the different kinds of formulas
        Sheet s = wb.getSheetAt(0);
        Cell cRefSName = s.getRow(1).getCell(3);
        Cell cRefWName = s.getRow(2).getCell(3);
View Full Code Here

      throw new AssertionFailedError("Identified bug 47312c - '"
          + leadingZeroCellRef + "' should parse as 'B1'.");
    }

    // create a defined name called 'B0' and try again
    Name n = wb.createName();
    n.setNameName("B0");
    n.setRefersToFormula("1+1");
    ptgs = HSSFFormulaParser.parse("B0", wb);
    confirmTokenClasses(ptgs, NamePtg.class);
  }
View Full Code Here

     */
    public void test48923() throws Exception {
       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48923.xlsx");
       assertEquals(4, wb.getNumberOfNames());
      
       Name b1 = wb.getName("NameB1");
       Name b2 = wb.getName("NameB2");
       Name sheet2 = wb.getName("NameSheet2");
       Name test = wb.getName("Test");
      
       assertNotNull(b1);
       assertEquals("NameB1", b1.getNameName());
       assertEquals("Sheet1", b1.getSheetName());
       assertEquals(-1, b1.getSheetIndex());
      
       assertNotNull(b2);
       assertEquals("NameB2", b2.getNameName());
       assertEquals("Sheet1", b2.getSheetName());
       assertEquals(-1, b2.getSheetIndex());
      
       assertNotNull(sheet2);
       assertEquals("NameSheet2", sheet2.getNameName());
       assertEquals("Sheet2", sheet2.getSheetName());
       assertEquals(-1, sheet2.getSheetIndex());
      
       assertNotNull(test);
       assertEquals("Test", test.getNameName());
       assertEquals("Sheet1", test.getSheetName());
       assertEquals(-1, test.getSheetIndex());
    }
View Full Code Here

        cell = sheet.getRow(0).getCell(0);
        assertEquals("#REF!*#REF!", cell.getCellFormula());
        assertEquals(Cell.CELL_TYPE_ERROR, evaluator.evaluateInCell(cell).getCellType());
        assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString());

        Name nm1 = wb.getName("sale_1");
        assertNotNull("name sale_1 should be present", nm1);
        assertEquals("Sheet1!#REF!", nm1.getRefersToFormula());
        Name nm2 = wb.getName("sale_2");
        assertNotNull("name sale_2 should be present", nm2);
        assertEquals("Sheet1!#REF!", nm2.getRefersToFormula());

        cell = sheet.getRow(1).getCell(0);
        assertEquals("sale_1*sale_2", cell.getCellFormula());
        assertEquals(Cell.CELL_TYPE_ERROR, evaluator.evaluateInCell(cell).getCellType());
        assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString());
View Full Code Here

    public void testNamedRanges() throws Exception {
      // First up, a new file
        XSSFWorkbook workbook = new XSSFWorkbook();
        assertEquals(0, workbook.getNumberOfNames());
       
        Name nameA = workbook.createName();
        nameA.setReference("A2");
        nameA.setNameName("ForA2");
       
        XSSFName nameB = workbook.createName();
        nameB.setReference("B3");
        nameB.setNameName("ForB3");
        nameB.setComment("B3 Comment");
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Name

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.