Package org.apache.poi.hssf.usermodel

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


            assertTrue("DividePtg",(ptgs[2] instanceof DividePtg));
  }
 
  /** bug 35027, underscore in sheet name*/
  public void testUnderscore() {
    HSSFWorkbook wb = new HSSFWorkbook();
     
      wb.createSheet("Cash_Flow");;
     
      HSSFSheet sheet = wb.createSheet("Test");
      HSSFRow row = sheet.createRow(0);
      HSSFCell cell;
     
      cell = row.createCell((short)0);
      cell.setCellFormula("Cash_Flow!A1");
View Full Code Here


    /**
     * Tests reading a file containing this ptg.
     */
    public void testReading() throws Exception
    {
        HSSFWorkbook workbook = loadWorkbook("IntersectionPtg.xls");
        HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell((short) 2);
        assertEquals("Wrong cell value", 5.0, cell.getNumericCellValue(), 0.0);
        assertEquals("Wrong cell formula", "SUM(A1:B2 B2:C3)", cell.getCellFormula());
    }
View Full Code Here

    protected void setUp() throws Exception
    {
        super.setUp();
        models = new ArrayList(3);
        factory = new ModelFactory();
        book = new HSSFWorkbook();
        ByteArrayOutputStream stream = (ByteArrayOutputStream)setupRunFile(book);   
        POIFSFileSystem fs = new POIFSFileSystem(
                                   new ByteArrayInputStream(stream.toByteArray())
                                   );
        in = fs.createDocumentInputStream("Workbook");
View Full Code Here

    assertEquals("TOTAL[", firstString.getValue());
    //the PTG order isn't 100% correct but it still works - dmui
  }

  public void testMacroFunction() {
    HSSFWorkbook w = new HSSFWorkbook();
    Ptg[] ptg = FormulaParser.parse("FOO()", w);

    // the name gets encoded as the first arg
    NamePtg tname = (NamePtg) ptg[0];
    assertEquals("FOO", tname.toFormulaString(w));
View Full Code Here

    assertTrue("first ptg is string", ptgs[0] instanceof StringPtg);
    assertTrue("second ptg is string", ptgs[1] instanceof StringPtg);
  }

  public void testWorksheetReferences() {
    HSSFWorkbook wb = new HSSFWorkbook();

    wb.createSheet("NoQuotesNeeded");
    wb.createSheet("Quotes Needed Here &#$@");

    HSSFSheet sheet = wb.createSheet("Test");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell;

    cell = row.createCell((short)0);
    cell.setCellFormula("NoQuotesNeeded!A1");
View Full Code Here

    assertTrue("DividePtg", (ptgs[2] instanceof DividePtg));
  }

  /** bug 35027, underscore in sheet name */
  public void testUnderscore() {
    HSSFWorkbook wb = new HSSFWorkbook();

    wb.createSheet("Cash_Flow");

    HSSFSheet sheet = wb.createSheet("Test");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell;

    cell = row.createCell((short)0);
    cell.setCellFormula("Cash_Flow!A1");
View Full Code Here

    assertTrue("IntPtg", (ptgs[1] instanceof IntPtg));
    assertTrue("DividePtg", (ptgs[2] instanceof DividePtg));
  }

  public void testExponentialInSheet() {
    HSSFWorkbook wb = new HSSFWorkbook();

    wb.createSheet("Cash_Flow");

    HSSFSheet sheet = wb.createSheet("Test");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short)0);
    String formula = null;

    cell.setCellFormula("1.3E21/3");
View Full Code Here

    formula = cell.getCellFormula();
    assertEquals("Exponential formula string", "-1.0/310.0*4000.0/30000.0", formula);
  }

  public void testNumbers() {
    HSSFWorkbook wb = new HSSFWorkbook();

    wb.createSheet("Cash_Flow");

    HSSFSheet sheet = wb.createSheet("Test");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short)0);
    String formula = null;

    // starts from decimal point
View Full Code Here

    formula = cell.getCellFormula();
    assertEquals("1.0", formula);
  }

  public void testRanges() {
    HSSFWorkbook wb = new HSSFWorkbook();

    wb.createSheet("Cash_Flow");

    HSSFSheet sheet = wb.createSheet("Test");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell((short)0);
    String formula = null;

    cell.setCellFormula("A1.A2");
View Full Code Here

  /**
   * Test for bug observable at svn revision 618865 (5-Feb-2008)<br/>
   * a formula consisting of a single no-arg function got rendered without the function braces
   */
  public void testToFormulaStringZeroArgFunction() {
    HSSFWorkbook book = new HSSFWorkbook();

    Ptg[] ptgs = {
        new FuncPtg(10),
    };
    assertEquals("NA()", FormulaParser.toFormulaString(book, ptgs));
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.usermodel.HSSFWorkbook

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.