Package org.apache.poi.hssf.usermodel

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


     * Constructor Workbook
     */

    Workbook()
    {
        _workbook    = new HSSFWorkbook();
        _sheet_index = 0;
    }
View Full Code Here


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

    }
    public void testExponentialInSheet() throws Exception {
        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

    /**
     * Tests reading a file containing this ptg.
     */
    public void testReading() throws Exception
    {
        HSSFWorkbook workbook = loadWorkbook("PercentPtg.xls");
        HSSFSheet sheet = workbook.getSheetAt(0);

        assertEquals("Wrong numeric value for original number", 53000.0,
                     sheet.getRow(0).getCell((short) 0).getNumericCellValue(), 0.0);
        assertEquals("Wrong numeric value for percent formula result", 5300.0,
                     sheet.getRow(1).getCell((short) 0).getNumericCellValue(), 0.0);
View Full Code Here

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

            throws IOException {
        File file = new File(dataDir, filename);
        InputStream stream = new BufferedInputStream(new FileInputStream(file));
        try
        {
            return new HSSFWorkbook(stream);
        }
        finally
        {
            stream.close();
        }
View Full Code Here

    /**
     * Tests reading a file containing this ptg.
     */
    public void testReading() throws Exception
    {
        HSSFWorkbook workbook = loadWorkbook("ErrPtg.xls");
        HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell((short) 0);
        assertEquals("Wrong cell value", 4.0, cell.getNumericCellValue(), 0.0);
        assertEquals("Wrong cell formula", "ERROR.TYPE(#REF!)", cell.getCellFormula());
    }
View Full Code Here

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

    /**
     * Tests reading a file containing this ptg.
     */
    public void testReading() throws Exception
    {
        HSSFWorkbook workbook = loadWorkbook("AreaErrPtg.xls");
        assertEquals("Wrong formula string for area error", "SUM(#REF!)",
                     workbook.getSheetAt(0).getRow(0).getCell((short) 2).getCellFormula());
    }
View Full Code Here

    public void testReadWriteDuplicatedRichText1()
            throws Exception
    {
        File file = new File( _test_file_path + File.separator + "duprich1.xls" );
        InputStream stream = new FileInputStream( file );
        HSSFWorkbook wb = new HSSFWorkbook( stream );
        stream.close();
        HSSFSheet sheet = wb.getSheetAt( 1 );
        assertEquals( "01/05 (Wed)", sheet.getRow( 0 ).getCell( (short) 8 ).getStringCellValue() );
        assertEquals( "01/05 (Wed)", sheet.getRow( 1 ).getCell( (short) 8 ).getStringCellValue() );

        file = TempFile.createTempFile( "testout", "xls" );
        FileOutputStream outStream = new FileOutputStream( file );
        wb.write( outStream );
        outStream.close();
        file.delete();

        // test the second file.
        file = new File( _test_file_path + File.separator + "duprich2.xls" );
        stream = new FileInputStream( file );
        wb = new HSSFWorkbook( stream );
        stream.close();
        sheet = wb.getSheetAt( 0 );
        int row = 0;
        assertEquals( "Testing", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
        assertEquals( "rich", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
        assertEquals( "text", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
        assertEquals( "strings", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
        assertEquals( "Testing", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );
        assertEquals( "Testing", sheet.getRow( row++ ).getCell( (short) 0 ).getStringCellValue() );

//        file = new File("/tryme.xls");
        file = TempFile.createTempFile( "testout", ".xls" );
        outStream = new FileOutputStream( file );
        wb.write( outStream );
        outStream.close();
        file.delete();
    }
View Full Code Here

        assertTrue("second ptg is string",ptg[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

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.