Examples of HSSFName


Examples of org.apache.poi.hssf.usermodel.HSSFName

    HSSFSheet s = workbook.createSheet("Foo");
    s.createRow(0).createCell(0).setCellValue(1.1);
    s.createRow(1).createCell(0).setCellValue(2.3);
    s.createRow(2).createCell(2).setCellValue(3.1);

    HSSFName name = workbook.createName();
    name.setNameName("testName");
    name.setRefersToFormula("A1:A2");

    confirmParseFormula(workbook);

    // Now make it a single cell
    name.setRefersToFormula("C3");
    confirmParseFormula(workbook);
   
    // And make it non-contiguous
    // using area unions
    name.setRefersToFormula("A1:A2,C3");
   
    confirmParseFormula(workbook);
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

  }

  public void testNamedRangeThatLooksLikeCell() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");
    HSSFName name = wb.createName();
    name.setRefersToFormula("Sheet1!B1");
    name.setNameName("pfy1");

    Ptg[] ptgs;
    try {
      ptgs = HSSFFormulaParser.parse("count(pfy1)", wb);
    } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

  /** Named ranges with backslashes, e.g. 'POI\\2009' */
  public void testBackSlashInNames() {
    HSSFWorkbook wb = new HSSFWorkbook();

    HSSFName name = wb.createName();
    name.setNameName("POI\\2009");
    name.setRefersToFormula("Sheet1!$A$1");

    HSSFSheet sheet = wb.createSheet();
    HSSFRow row = sheet.createRow(0);

    HSSFCell cell_C1 =  row.createCell(2);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

  public void testParseComplexName() {

    // Mock up a spreadsheet to match the critical details of the sample
    HSSFWorkbook wb = new HSSFWorkbook();
    wb.createSheet("Sheet1");
    HSSFName definedName = wb.createName();
    definedName.setNameName("foo");
    definedName.setRefersToFormula("Sheet1!B2");

    // Set the complex flag - POI doesn't usually manipulate this flag
    NameRecord nameRec = TestHSSFName.getNameRecord(definedName);
    nameRec.setOptionFlag((short)0x10); // 0x10 -> complex
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    TestcaseRecordInputStream.confirmRecordEncoding(NameRecord.sid, data, data2);
  }
  public void testFormulaRelAbs_bug46174() {
    // perhaps this testcase belongs on TestHSSFName
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFName name = wb.createName();
    wb.createSheet("Sheet1");
    name.setNameName("test");
    name.setRefersToFormula("Sheet1!$B$3");
    if (name.getRefersToFormula().equals("Sheet1!B3")) {
      throw new AssertionFailedError("Identified bug 46174");
    }
    assertEquals("Sheet1!$B$3", name.getRefersToFormula());
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    assertEquals("Sheet1!$B$3", name.getRefersToFormula());
  }
  public void testFormulaGeneral() {
    // perhaps this testcase belongs on TestHSSFName
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFName name = wb.createName();
    wb.createSheet("Sheet1");
    name.setNameName("test");
    name.setRefersToFormula("Sheet1!A1+Sheet1!A2");
    assertEquals("Sheet1!A1+Sheet1!A2", name.getRefersToFormula());
    name.setRefersToFormula("5*6");
    assertEquals("5*6", name.getRefersToFormula());
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    HSSFSheet s = workbook.createSheet("Foo");
    s.createRow(0).createCell((short)0).setCellValue(1.1);
    s.createRow(1).createCell((short)0).setCellValue(2.3);
    s.createRow(2).createCell((short)2).setCellValue(3.1);

    HSSFName name = workbook.createName();
    name.setNameName("testName");
    name.setReference("A1:A2");

    fp = HSSFFormulaEvaluator.getUnderlyingParser(workbook, "SUM(testName)");
    fp.parse();
    ptgs = fp.getRPNPtg();
    assertTrue("two tokens expected, got "+ptgs.length,ptgs.length == 2);
    assertEquals(NamePtg.class, ptgs[0].getClass());
    assertEquals(FuncVarPtg.class, ptgs[1].getClass());

    // Now make it a single cell
    name.setReference("C3");

    fp = HSSFFormulaEvaluator.getUnderlyingParser(workbook, "SUM(testName)");
    fp.parse();
    ptgs = fp.getRPNPtg();
    assertTrue("two tokens expected, got "+ptgs.length,ptgs.length == 2);
    assertEquals(NamePtg.class, ptgs[0].getClass());
    assertEquals(FuncVarPtg.class, ptgs[1].getClass());
   
    // And make it non-contiguous
    name.setReference("A1:A2,C3");
    fp = HSSFFormulaEvaluator.getUnderlyingParser(workbook, "SUM(testName)");
    fp.parse();
    ptgs = fp.getRPNPtg();
    assertTrue("two tokens expected, got "+ptgs.length,ptgs.length == 2);
    assertEquals(NamePtg.class, ptgs[0].getClass());
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

        HSSFSheet sheet = wb.createSheet();
        wb.setSheetName(0, "Sheet1");
        HSSFRow row = sheet.createRow(0);
        HSSFCell cell = row.createCell((short)0);

        HSSFName hssfName = wb.createName();
        hssfName.setNameName("myFunc");
       
        cell.setCellFormula("myFunc()");
        String actualFormula=cell.getCellFormula();
        assertEquals("myFunc()", actualFormula);
   
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

  }
 
  public void testNamedRangeThatLooksLikeCell() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");
    HSSFName name = wb.createName();
    name.setReference("Sheet1!B1");
    name.setNameName("pfy1");

    Ptg[] ptgs;
    try {
      ptgs = FormulaParser.parse("count(pfy1)", wb);
    } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    HSSFSheet s = workbook.createSheet("Foo");
    s.createRow(0).createCell(0).setCellValue(1.1);
    s.createRow(1).createCell(0).setCellValue(2.3);
    s.createRow(2).createCell(2).setCellValue(3.1);

    HSSFName name = workbook.createName();
    name.setNameName("testName");
    name.setRefersToFormula("A1:A2");

    confirmParseFormula(workbook);

    // Now make it a single cell
    name.setRefersToFormula("C3");
    confirmParseFormula(workbook);

    // And make it non-contiguous
    // using area unions
    name.setRefersToFormula("A1:A2,C3");

    confirmParseFormula(workbook);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.