Package org.apache.poi.hssf.model

Examples of org.apache.poi.hssf.model.Workbook


    FormulaRecord[] fRecs = mockListen.getFormulaRecords();
   
    // Check our formula records
    assertEquals(6, fRecs.length);
   
    Workbook stubWB = listener.getStubWorkbook();
    assertNotNull(stubWB);
    HSSFWorkbook stubHSSF = listener.getStubHSSFWorkbook();
    assertNotNull(stubHSSF);
   
    // Check these stubs have the right stuff on them
    assertEquals("Sheet1", stubWB.getSheetName(0));
    assertEquals("S2", stubWB.getSheetName(1));
    assertEquals("Sh3", stubWB.getSheetName(2));
   
    // Check we can get the formula without breaking
    for(int i=0; i<fRecs.length; i++) {
      HSSFFormulaParser.toFormulaString(stubHSSF, fRecs[i].getParsedExpression());
    }
View Full Code Here


              throw new RuntimeException("Not yet handled embedded models");
             } else {
              BOFRecord bof = (BOFRecord)rec;
              switch (bof.getType()) {
               case BOFRecord.TYPE_WORKBOOK:
                 currentmodel = new Workbook();
               break;
               case BOFRecord.TYPE_WORKSHEET:
                 currentmodel = Sheet.createSheet();
               break;
              default:
View Full Code Here

    }

    public void testDiscontinousReference() throws Exception {
        InputStream is = HSSFTestDataSamples.openSampleFileStream("44167.xls");
        HSSFWB wb = new HSSFWB(is);
        Workbook workbook = wb.getWorkbook();
        HSSFEvaluationWorkbook eb = HSSFEvaluationWorkbook.create(wb);

        assertEquals(1, wb.getNumberOfNames());
        String sheetName = "Tabelle1";
        String rawRefA = "$C$10:$C$14";
        String rawRefB = "$C$16:$C$18";
        String refA = sheetName + "!" + rawRefA;
        String refB = sheetName + "!" + rawRefB;
        String ref = refA + "," + refB;

        // Check the low level record
        NameRecord nr = workbook.getNameRecord(0);
        assertNotNull(nr);
        assertEquals("test", nr.getNameText());

        Ptg[] def =nr.getNameDefinition();
        assertEquals(4, def.length);
View Full Code Here

     */
    public void testOnARealFile() {

        HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls");
        HSSFSheet sheet       = workbook.getSheetAt(0);
        Workbook wb           = workbook.getWorkbook();

        HSSFRow  row;
        HSSFCell cell;
        HSSFCellStyle style;

View Full Code Here

     * Test the backup field gets set as expected.
     */
    public void testBackupRecord() {
        HSSFWorkbook wb = new HSSFWorkbook();
    wb.createSheet();
    Workbook workbook = wb.getWorkbook();
        BackupRecord record   = workbook.getBackupRecord();

        assertEquals(0, record.getBackup());
        wb.setBackupFlag(true);
        assertEquals(1, record.getBackup());
    }
View Full Code Here

        assertEquals(1, wb.getNumberOfNames());
        assertEquals(3, wb.getNumberOfSheets());

        // Check all names fit within range, and use
        //  DeletedArea3DPtg
        Workbook w = wb.getWorkbook();
        for(int i=0; i<w.getNumNames(); i++) {
            NameRecord r = w.getNameRecord(i);
            assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());

            Ptg[] nd = r.getNameDefinition();
            assertEquals(1, nd.length);
            assertTrue(nd[0] instanceof DeletedArea3DPtg);
        }


        // Delete the 2nd sheet
        wb.removeSheetAt(1);


        // Re-check
        assertEquals(1, wb.getNumberOfNames());
        assertEquals(2, wb.getNumberOfSheets());

        for(int i=0; i<w.getNumNames(); i++) {
            NameRecord r = w.getNameRecord(i);
            assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());

            Ptg[] nd = r.getNameDefinition();
            assertEquals(1, nd.length);
            assertTrue(nd[0] instanceof DeletedArea3DPtg);
        }


        // Save and re-load
        wb = writeOutAndReadBack(wb);
        w = wb.getWorkbook();

        assertEquals(1, wb.getNumberOfNames());
        assertEquals(2, wb.getNumberOfSheets());

        for(int i=0; i<w.getNumNames(); i++) {
            NameRecord r = w.getNameRecord(i);
            assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());

            Ptg[] nd = r.getNameDefinition();
            assertEquals(1, nd.length);
            assertTrue(nd[0] instanceof DeletedArea3DPtg);
View Full Code Here

    public void testBackupRecord()
        throws Exception
    {
        HSSFWorkbook wb       = new HSSFWorkbook();
        HSSFSheet    s        = wb.createSheet();
        Workbook     workbook = wb.getWorkbook();
        BackupRecord record   = workbook.getBackupRecord();

        assertEquals(0, record.getBackup());
        wb.setBackupFlag(true);
        assertEquals(1, record.getBackup());
    }
View Full Code Here

     * sets the name of the named range
     * @param nameName named range name to set
     */
    public void setNameName(String nameName){
        _definedNameRec.setNameText(nameName);
        Workbook wb = _book.getWorkbook();

        //Check to ensure no other names have the same case-insensitive name
        for ( int i = wb.getNumNames()-1; i >=0; i-- )
        {
            NameRecord rec = wb.getNameRecord(i);
            if (rec != _definedNameRec) {
                if (rec.getNameText().equalsIgnoreCase(getNameName()))
                    throw new IllegalArgumentException("The workbook already contains this name (case-insensitive)");
            }
        }
View Full Code Here

              throw new RuntimeException("Not yet handled embedded models")
             } else {
              BOFRecord bof = (BOFRecord)rec;
              switch (bof.getType()) {
               case BOFRecord.TYPE_WORKBOOK:
                 currentmodel = new Workbook();                
               break;
               case BOFRecord.TYPE_WORKSHEET:
                 currentmodel = new Sheet();                                 
               break;
              default:
View Full Code Here

    public void testBackupRecord()
        throws Exception
    {
        HSSFWorkbook wb       = new HSSFWorkbook();
        wb.createSheet();
        Workbook     workbook = wb.getWorkbook();
        BackupRecord record   = workbook.getBackupRecord();

        assertEquals(0, record.getBackup());
        wb.setBackupFlag(true);
        assertEquals(1, record.getBackup());
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.model.Workbook

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.