Package org.apache.poi.hssf.model

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


     * Test horizontally centered output.
     */
    public void testHorizontallyCenter() {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet s = wb.createSheet();
        Sheet sheet = s.getSheet();
        HCenterRecord record = sheet.getPageSettings().getHCenter();

        assertEquals(false, record.getHCenter());
        s.setHorizontallyCenter(true);
        assertEquals(true, record.getHCenter());
    }
View Full Code Here


     * Test WSBboolRecord fields get set in the user model.
     */
    public void testWSBool() {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet s = wb.createSheet();
        Sheet sheet = s.getSheet();
        WSBoolRecord record =
                (WSBoolRecord) sheet.findFirstRecordBySid(WSBoolRecord.sid);

        // Check defaults
        assertEquals(true, record.getAlternateExpression());
        assertEquals(true, record.getAlternateFormula());
        assertEquals(false, record.getAutobreaks());
View Full Code Here

     * Test that the ProtectRecord is included when creating or cloning a sheet
     */
    public void testProtect() {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet hssfSheet = workbook.createSheet();
        Sheet sheet = hssfSheet.getSheet();
        ProtectRecord protect = sheet.getProtect();

        assertFalse(protect.getProtect());

        // This will tell us that cloneSheet, and by extension,
        // the list forms of createSheet leave us with an accessible
        // ProtectRecord.
        hssfSheet.protectSheet("secret");
        Sheet cloned = sheet.cloneSheet();
        assertNotNull(cloned.getProtect());
        assertTrue(hssfSheet.getProtect());
    }
View Full Code Here

    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

     * 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

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

            recOffset = sheet.getEofLoc()+1;
            HSSFSheet hsheet = new HSSFSheet(workbook, sheet);

            sheets.add(hsheet);

            // workbook.setSheetName(sheets.size() -1, "Sheet"+sheets.size());
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

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.