Search in sources :

Example 1 with TabIdRecord

use of org.apache.poi.hssf.record.TabIdRecord in project poi by apache.

the class InternalWorkbook method fixTabIdRecord.

/**
     * make the tabid record look like the current situation.
     */
private void fixTabIdRecord() {
    Record rec = records.get(records.getTabpos());
    // we use the same check on Tabpos as done in other places
    if (records.getTabpos() <= 0) {
        return;
    }
    TabIdRecord tir = (TabIdRecord) rec;
    short[] tia = new short[boundsheets.size()];
    for (short k = 0; k < tia.length; k++) {
        tia[k] = k;
    }
    tir.setTabIdArray(tia);
}
Also used : TabIdRecord(org.apache.poi.hssf.record.TabIdRecord) WindowProtectRecord(org.apache.poi.hssf.record.WindowProtectRecord) PasswordRev4Record(org.apache.poi.hssf.record.PasswordRev4Record) DateWindow1904Record(org.apache.poi.hssf.record.DateWindow1904Record) FormatRecord(org.apache.poi.hssf.record.FormatRecord) BookBoolRecord(org.apache.poi.hssf.record.BookBoolRecord) StyleRecord(org.apache.poi.hssf.record.StyleRecord) RecalcIdRecord(org.apache.poi.hssf.record.RecalcIdRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) HideObjRecord(org.apache.poi.hssf.record.HideObjRecord) Record(org.apache.poi.hssf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) HyperlinkRecord(org.apache.poi.hssf.record.HyperlinkRecord) ProtectionRev4Record(org.apache.poi.hssf.record.ProtectionRev4Record) EOFRecord(org.apache.poi.hssf.record.EOFRecord) MMSRecord(org.apache.poi.hssf.record.MMSRecord) PrecisionRecord(org.apache.poi.hssf.record.PrecisionRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) CountryRecord(org.apache.poi.hssf.record.CountryRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) NameCommentRecord(org.apache.poi.hssf.record.NameCommentRecord) FnGroupCountRecord(org.apache.poi.hssf.record.FnGroupCountRecord) DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) BackupRecord(org.apache.poi.hssf.record.BackupRecord) EscherSplitMenuColorsRecord(org.apache.poi.ddf.EscherSplitMenuColorsRecord) ExternSheetRecord(org.apache.poi.hssf.record.ExternSheetRecord) WriteAccessRecord(org.apache.poi.hssf.record.WriteAccessRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) CodepageRecord(org.apache.poi.hssf.record.CodepageRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) FilePassRecord(org.apache.poi.hssf.record.FilePassRecord) FontRecord(org.apache.poi.hssf.record.FontRecord) UseSelFSRecord(org.apache.poi.hssf.record.UseSelFSRecord) WindowOneRecord(org.apache.poi.hssf.record.WindowOneRecord) WriteProtectRecord(org.apache.poi.hssf.record.WriteProtectRecord) ProtectRecord(org.apache.poi.hssf.record.ProtectRecord) InterfaceHdrRecord(org.apache.poi.hssf.record.InterfaceHdrRecord) DSFRecord(org.apache.poi.hssf.record.DSFRecord) InterfaceEndRecord(org.apache.poi.hssf.record.InterfaceEndRecord) SupBookRecord(org.apache.poi.hssf.record.SupBookRecord) SSTRecord(org.apache.poi.hssf.record.SSTRecord) TabIdRecord(org.apache.poi.hssf.record.TabIdRecord) PasswordRecord(org.apache.poi.hssf.record.PasswordRecord) PaletteRecord(org.apache.poi.hssf.record.PaletteRecord) EscherDgRecord(org.apache.poi.ddf.EscherDgRecord) ExtSSTRecord(org.apache.poi.hssf.record.ExtSSTRecord) ExtendedFormatRecord(org.apache.poi.hssf.record.ExtendedFormatRecord) FileSharingRecord(org.apache.poi.hssf.record.FileSharingRecord) RefreshAllRecord(org.apache.poi.hssf.record.RefreshAllRecord)

Example 2 with TabIdRecord

use of org.apache.poi.hssf.record.TabIdRecord in project poi by apache.

the class TestBugs method bug46664.

/**
     * Newly created sheets need to get a
     *  proper TabID, otherwise print setup
     *  gets confused on them.
     * Also ensure that print setup refs are
     *  by reference not value
     */
@Test
public void bug46664() throws Exception {
    HSSFWorkbook wb1 = new HSSFWorkbook();
    HSSFSheet sheet = wb1.createSheet("new_sheet");
    HSSFRow row = sheet.createRow((short) 0);
    row.createCell(0).setCellValue(new HSSFRichTextString("Column A"));
    row.createCell(1).setCellValue(new HSSFRichTextString("Column B"));
    row.createCell(2).setCellValue(new HSSFRichTextString("Column C"));
    row.createCell(3).setCellValue(new HSSFRichTextString("Column D"));
    row.createCell(4).setCellValue(new HSSFRichTextString("Column E"));
    row.createCell(5).setCellValue(new HSSFRichTextString("Column F"));
    //set print area from column a to column c (on first row)
    wb1.setPrintArea(//sheet index
    0, //start column
    0, //end column
    2, //start row
    0, //end row
    0);
    HSSFWorkbook wb2 = writeOutAndReadBack(wb1);
    wb1.close();
    // Ensure the tab index
    TabIdRecord tr = null;
    for (Record r : wb2.getWorkbook().getRecords()) {
        if (r instanceof TabIdRecord) {
            tr = (TabIdRecord) r;
        }
    }
    assertNotNull(tr);
    assertEquals(1, tr._tabids.length);
    assertEquals(0, tr._tabids[0]);
    // Ensure the print setup
    assertEquals("new_sheet!$A$1:$C$1", wb2.getPrintArea(0));
    HSSFName printArea = wb2.getName("Print_Area");
    assertNotNull(printArea);
    assertEquals("new_sheet!$A$1:$C$1", printArea.getRefersToFormula());
    // Needs reference not value
    NameRecord nr = wb2.getWorkbook().getNameRecord(wb2.getNameIndex("Print_Area"));
    assertEquals("Print_Area", nr.getNameText());
    assertEquals(1, nr.getNameDefinition().length);
    assertEquals("new_sheet!$A$1:$C$1", ((Area3DPtg) nr.getNameDefinition()[0]).toFormulaString(HSSFEvaluationWorkbook.create(wb2)));
    assertEquals('R', nr.getNameDefinition()[0].getRVAType());
    wb2.close();
}
Also used : TabIdRecord(org.apache.poi.hssf.record.TabIdRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) Record(org.apache.poi.hssf.record.Record) EmbeddedObjectRefSubRecord(org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord) CommonObjectDataSubRecord(org.apache.poi.hssf.record.CommonObjectDataSubRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) TabIdRecord(org.apache.poi.hssf.record.TabIdRecord) Test(org.junit.Test)

Aggregations

NameRecord (org.apache.poi.hssf.record.NameRecord)2 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)1 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)1 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)1 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)1 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)1 EscherRecord (org.apache.poi.ddf.EscherRecord)1 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)1 EscherSplitMenuColorsRecord (org.apache.poi.ddf.EscherSplitMenuColorsRecord)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BackupRecord (org.apache.poi.hssf.record.BackupRecord)1 BookBoolRecord (org.apache.poi.hssf.record.BookBoolRecord)1 BoundSheetRecord (org.apache.poi.hssf.record.BoundSheetRecord)1 CodepageRecord (org.apache.poi.hssf.record.CodepageRecord)1 CommonObjectDataSubRecord (org.apache.poi.hssf.record.CommonObjectDataSubRecord)1 CountryRecord (org.apache.poi.hssf.record.CountryRecord)1 DSFRecord (org.apache.poi.hssf.record.DSFRecord)1 DateWindow1904Record (org.apache.poi.hssf.record.DateWindow1904Record)1 DrawingGroupRecord (org.apache.poi.hssf.record.DrawingGroupRecord)1 EOFRecord (org.apache.poi.hssf.record.EOFRecord)1