Search in sources :

Example 6 with Record

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

the class LinkTable method findFirstRecordLocBySid.

/**
	 * copied from Workbook
	 */
private int findFirstRecordLocBySid(short sid) {
    int index = 0;
    for (Iterator<Record> iterator = _workbookRecordList.iterator(); iterator.hasNext(); ) {
        Record record = iterator.next();
        if (record.getSid() == sid) {
            return index;
        }
        index++;
    }
    return -1;
}
Also used : CRNCountRecord(org.apache.poi.hssf.record.CRNCountRecord) Record(org.apache.poi.hssf.record.Record) SupBookRecord(org.apache.poi.hssf.record.SupBookRecord) CRNRecord(org.apache.poi.hssf.record.CRNRecord) ExternalNameRecord(org.apache.poi.hssf.record.ExternalNameRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) CountryRecord(org.apache.poi.hssf.record.CountryRecord) NameCommentRecord(org.apache.poi.hssf.record.NameCommentRecord) ExternSheetRecord(org.apache.poi.hssf.record.ExternSheetRecord)

Example 7 with Record

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

the class CFRecordsAggregate method createCFAggregate.

/**
     * Create CFRecordsAggregate from a list of CF Records
     * @param rs - the stream to read from
     * @return CFRecordsAggregate object
     */
public static CFRecordsAggregate createCFAggregate(RecordStream rs) {
    Record rec = rs.getNext();
    if (rec.getSid() != CFHeaderRecord.sid && rec.getSid() != CFHeader12Record.sid) {
        throw new IllegalStateException("next record sid was " + rec.getSid() + " instead of " + CFHeaderRecord.sid + " or " + CFHeader12Record.sid + " as expected");
    }
    CFHeaderBase header = (CFHeaderBase) rec;
    int nRules = header.getNumberOfConditionalFormats();
    CFRuleBase[] rules = new CFRuleBase[nRules];
    for (int i = 0; i < rules.length; i++) {
        rules[i] = (CFRuleBase) rs.getNext();
    }
    return new CFRecordsAggregate(header, rules);
}
Also used : CFRuleBase(org.apache.poi.hssf.record.CFRuleBase) Record(org.apache.poi.hssf.record.Record) CFRuleRecord(org.apache.poi.hssf.record.CFRuleRecord) CFRule12Record(org.apache.poi.hssf.record.CFRule12Record) CFHeader12Record(org.apache.poi.hssf.record.CFHeader12Record) CFHeaderRecord(org.apache.poi.hssf.record.CFHeaderRecord) CFHeaderBase(org.apache.poi.hssf.record.CFHeaderBase)

Example 8 with Record

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

the class ValueRecordsAggregate method visitCellsForRow.

public void visitCellsForRow(int rowIndex, RecordVisitor rv) {
    CellValueRecordInterface[] rowCells = records[rowIndex];
    if (rowCells == null) {
        throw new IllegalArgumentException("Row [" + rowIndex + "] is empty");
    }
    for (int i = 0; i < rowCells.length; i++) {
        RecordBase cvr = (RecordBase) rowCells[i];
        if (cvr == null) {
            continue;
        }
        int nBlank = countBlanks(rowCells, i);
        if (nBlank > 1) {
            rv.visitRecord(createMBR(rowCells, i, nBlank));
            i += nBlank - 1;
        } else if (cvr instanceof RecordAggregate) {
            RecordAggregate agg = (RecordAggregate) cvr;
            agg.visitContainedRecords(rv);
        } else {
            rv.visitRecord((Record) cvr);
        }
    }
}
Also used : CellValueRecordInterface(org.apache.poi.hssf.record.CellValueRecordInterface) RecordBase(org.apache.poi.hssf.record.RecordBase) Record(org.apache.poi.hssf.record.Record) StringRecord(org.apache.poi.hssf.record.StringRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord)

Example 9 with Record

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

the class InternalWorkbook method setSheetOrder.

/**
     * sets the order of appearance for a given sheet.
     *
     * @param sheetname the name of the sheet to reorder
     * @param pos the position that we want to insert the sheet into (0 based)
     */
public void setSheetOrder(String sheetname, int pos) {
    int sheetNumber = getSheetIndex(sheetname);
    //remove the sheet that needs to be reordered and place it in the spot we want
    boundsheets.add(pos, boundsheets.remove(sheetNumber));
    // also adjust order of Records, calculate the position of the Boundsheets via getBspos()...
    int initialBspos = records.getBspos();
    int pos0 = initialBspos - (boundsheets.size() - 1);
    Record removed = records.get(pos0 + sheetNumber);
    records.remove(pos0 + sheetNumber);
    records.add(pos0 + pos, removed);
    records.setBspos(initialBspos);
}
Also used : 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 10 with Record

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

the class HSSFWorkbook method getAllPictures.

/**
     * Gets all pictures from the Workbook.
     *
     * @return the list of pictures (a list of {@link HSSFPictureData} objects.)
     */
@Override
public List<HSSFPictureData> getAllPictures() {
    // The drawing group record always exists at the top level, so we won't need to do this recursively.
    List<HSSFPictureData> pictures = new ArrayList<HSSFPictureData>();
    for (Record r : workbook.getRecords()) {
        if (r instanceof AbstractEscherHolderRecord) {
            ((AbstractEscherHolderRecord) r).decode();
            List<EscherRecord> escherRecords = ((AbstractEscherHolderRecord) r).getEscherRecords();
            searchForPictures(escherRecords, pictures);
        }
    }
    return Collections.unmodifiableList(pictures);
}
Also used : AbstractEscherHolderRecord(org.apache.poi.hssf.record.AbstractEscherHolderRecord) ArrayList(java.util.ArrayList) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) RecalcIdRecord(org.apache.poi.hssf.record.RecalcIdRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) Record(org.apache.poi.hssf.record.Record) AbstractEscherHolderRecord(org.apache.poi.hssf.record.AbstractEscherHolderRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) EscherBlipRecord(org.apache.poi.ddf.EscherBlipRecord) DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) BackupRecord(org.apache.poi.hssf.record.BackupRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) LabelSSTRecord(org.apache.poi.hssf.record.LabelSSTRecord) LabelRecord(org.apache.poi.hssf.record.LabelRecord) FilePassRecord(org.apache.poi.hssf.record.FilePassRecord) FontRecord(org.apache.poi.hssf.record.FontRecord) SSTRecord(org.apache.poi.hssf.record.SSTRecord) ExtendedFormatRecord(org.apache.poi.hssf.record.ExtendedFormatRecord) EscherRecord(org.apache.poi.ddf.EscherRecord)

Aggregations

Record (org.apache.poi.hssf.record.Record)78 EOFRecord (org.apache.poi.hssf.record.EOFRecord)42 BOFRecord (org.apache.poi.hssf.record.BOFRecord)36 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)36 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)30 Test (org.junit.Test)25 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)24 NumberRecord (org.apache.poi.hssf.record.NumberRecord)24 RowRecord (org.apache.poi.hssf.record.RowRecord)24 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)23 NameRecord (org.apache.poi.hssf.record.NameRecord)23 ArrayList (java.util.ArrayList)21 EscherRecord (org.apache.poi.ddf.EscherRecord)21 BlankRecord (org.apache.poi.hssf.record.BlankRecord)21 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)21 UnknownRecord (org.apache.poi.hssf.record.UnknownRecord)19 BoundSheetRecord (org.apache.poi.hssf.record.BoundSheetRecord)18 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)18 StringRecord (org.apache.poi.hssf.record.StringRecord)18 NoteRecord (org.apache.poi.hssf.record.NoteRecord)17