Package org.apache.poi.hssf.model

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


    public void testProtectSheet() {
        short expected = (short)0xfef1;
  HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet s = wb.createSheet();
        s.protectSheet("abcdefghij");
        Sheet sheet = s.getSheet();
  ProtectRecord protect = sheet.getProtect();
  PasswordRecord pass = sheet.getPassword();
        assertTrue("protection should be on",protect.getProtect());
        assertTrue("object protection should be on",sheet.isProtected()[1]);
        assertTrue("scenario protection should be on",sheet.isProtected()[2]);
        assertEquals("well known value for top secret hash should be "+Integer.toHexString(expected).substring(4),expected,pass.getPassword());
    }
View Full Code Here


        // convert all LabelRecord records to LabelSSTRecord
        convertLabelRecords(records, recOffset);       
        while (recOffset < records.size())
        {
            Sheet sheet = Sheet.createSheet(records, sheetNum++, recOffset );

            recOffset = sheet.getEofLoc()+1;
            if (recOffset == 1)
            {
                break;
            }
View Full Code Here

                         .getJavaDate(firstCell.getNumericCellValue()));
        HSSFRow  row  = sheet.createRow(( short ) 15);
        HSSFCell cell = row.createCell(( short ) 1);

        cell.setCellValue(22);
        Sheet newSheet = workbook.getSheetAt(0).getSheet();
        List  records  = newSheet.getRecords();

        //System.out.println("BOF Assertion");
        assertTrue(records.get(0) instanceof BOFRecord);
        //System.out.println("EOF Assertion");
        assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
View Full Code Here

     * errors are particularly hard to track down.  This test ensures that HSSFWorkbook throws
     * a specific exception as soon as the situation is detected. See bugzilla 45066
     */
    public void testSheetSerializeSizeMismatch_bug45066() {
        HSSFWorkbook wb = new HSSFWorkbook();
        Sheet sheet = wb.createSheet("Sheet1").getSheet();
        List<RecordBase> sheetRecords = sheet.getRecords();
        // one way (of many) to cause the discrepancy is with a badly behaved record:
        sheetRecords.add(new BadlyBehavedRecord());
        // There is also much logic inside Sheet that (if buggy) might also cause the discrepancy
        try {
            wb.getBytes();
View Full Code Here

        ur(UnknownRecord.USERSVIEWEND_01AB, "01, 00"),

        EOFRecord.instance,
    };
    RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
    Sheet sheet;
    try {
      sheet = Sheet.createSheet(rs);
    } catch (RuntimeException e) {
      if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
        throw new AssertionFailedError("Identified bug 46480");
      }
      throw e;
    }

    RecordCollector rv = new RecordCollector();
    sheet.visitContainedRecords(rv, rowIx);
    Record[] outRecs = rv.getRecords();
    assertEquals(13, outRecs.length);
  }
View Full Code Here

        new WindowTwoRecord(),
        ur(UnknownRecord.HEADER_FOOTER_089C, "9C 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 60 00 00 00 00 00 00 00 00"),
        EOFRecord.instance,
    };
    RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
    Sheet sheet = Sheet.createSheet(rs);

    RecordCollector rv = new RecordCollector();
    sheet.visitContainedRecords(rv, 0);
    Record[] outRecs = rv.getRecords();
    if (outRecs[4] == EOFRecord.instance) {
      throw new AssertionFailedError("Identified bug 46953 - EOF incorrectly appended to PSB");
    }
    assertEquals(recs.length+1, outRecs.length); // +1 for index record
View Full Code Here

        new WindowTwoRecord(),
        EOFRecord.instance,
    };
    RecordStream rs = new RecordStream(Arrays.asList(recs), 0);

    Sheet sheet;
    try {
      sheet = Sheet.createSheet(rs);
    } catch (RuntimeException e) {
      if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
        throw new AssertionFailedError("Identified bug 47199a - failed to process late margings records");
      }
      throw e;
    }

    RecordCollector rv = new RecordCollector();
    sheet.visitContainedRecords(rv, 0);
    Record[] outRecs = rv.getRecords();
    assertEquals(recs.length+1, outRecs.length); // +1 for index record

    assertEquals(BOFRecord.class, outRecs[0].getClass());
    assertEquals(IndexRecord.class, outRecs[1].getClass());
View Full Code Here

                         .getJavaDate(firstCell.getNumericCellValue(), false));
        HSSFRow  row  = sheet.createRow(15);
        HSSFCell cell = row.createCell(1);

        cell.setCellValue(22);
        Sheet newSheet = workbook.getSheetAt(0).getSheet();
        List  records  = newSheet.getRecords();

        assertTrue(records.get(0) instanceof BOFRecord);
        assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
    }
View Full Code Here

     * Test the gridset field gets set as expected.
     */
    public void testBackupRecord() {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet s = wb.createSheet();
        Sheet sheet = s.getSheet();

        assertEquals(true, sheet.getGridsetRecord().getGridset());
        s.setGridsPrinted(true);
        assertEquals(false, sheet.getGridsetRecord().getGridset());
    }
View Full Code Here

     * Test vertically centered output.
     */
    public void testVerticallyCenter() {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet s = wb.createSheet();
        Sheet sheet = s.getSheet();
        VCenterRecord record = sheet.getPageSettings().getVCenter();

        assertEquals(false, record.getVCenter());
        s.setVerticallyCenter(true);
        assertEquals(true, record.getVCenter());

View Full Code Here

TOP

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

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.