FileDocCategorySizeDatePackage
RowRecord.javaAPI DocApache Poi 3.0.113841Mon Jan 01 12:39:40 GMT 2007org.apache.poi.hssf.record

RowRecord

public class RowRecord extends Record implements Comparable
Title: Row Record

Description: stores the row information for the sheet.

REFERENCE: PG 379 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

author
Andrew C. Oliver (acoliver at apache dot org)
author
Jason Height (jheight at chariot dot net dot au)
version
2.0-pre

Fields Summary
public static final short
sid
public static final int
MAX_ROW_NUMBER
The maximum row number that excel can handle (zero bazed) ie 65536 rows is max number of rows.
private int
field_1_row_number
private short
field_2_first_col
private short
field_3_last_col
private short
field_4_height
private short
field_5_optimize
private short
field_6_reserved
private short
field_7_option_flags
private static final BitField
outlineLevel
private static final BitField
colapsed
private static final BitField
zeroHeight
private static final BitField
badFontHeight
private static final BitField
formatted
private short
field_8_xf_index
Constructors Summary
public RowRecord()

   // only if isFormatted

     
    
    
public RowRecord(RecordInputStream in)
Constructs a Row record and sets its fields appropriately.

param
id id must be 0x208 or an exception will be throw upon validation
param
size the size of the data area of the record
param
data data of the record (should not contain sid/len)

        super(in);
    
Methods Summary
public java.lang.Objectclone()

      RowRecord rec = new RowRecord();
      rec.field_1_row_number = field_1_row_number;
      rec.field_2_first_col = field_2_first_col;
      rec.field_3_last_col = field_3_last_col;
      rec.field_4_height = field_4_height;
      rec.field_5_optimize = field_5_optimize;
      rec.field_6_reserved = field_6_reserved;
      rec.field_7_option_flags = field_7_option_flags;
      rec.field_8_xf_index = field_8_xf_index;
      return rec;
    
public intcompareTo(java.lang.Object obj)

        RowRecord loc = ( RowRecord ) obj;

        if (this.getRowNumber() == loc.getRowNumber())
        {
            return 0;
        }
        if (this.getRowNumber() < loc.getRowNumber())
        {
            return -1;
        }
        if (this.getRowNumber() > loc.getRowNumber())
        {
            return 1;
        }
        return -1;
    
public booleanequals(java.lang.Object obj)

        if (!(obj instanceof RowRecord))
        {
            return false;
        }
        RowRecord loc = ( RowRecord ) obj;

        if (this.getRowNumber() == loc.getRowNumber())
        {
            return true;
        }
        return false;
    
protected voidfillFields(org.apache.poi.hssf.record.RecordInputStream in)

        //field_1_row_number   = LittleEndian.getShort(data, 0 + offset);
        field_1_row_number   = in.readUShort();
        field_2_first_col    = in.readShort();
        field_3_last_col     = in.readShort();
        field_4_height       = in.readShort();
        field_5_optimize     = in.readShort();
        field_6_reserved     = in.readShort();
        field_7_option_flags = in.readShort();
        field_8_xf_index     = in.readShort();
    
public booleangetBadFontHeight()
get whether the font and row height are not compatible

return
- f -true if they aren't compatible (damn not logic)
see
#getOptionFlags()

        return badFontHeight.isSet(field_7_option_flags);
    
public booleangetColapsed()
get whether or not to colapse this row

return
c - colapse or not
see
#getOptionFlags()

        return (colapsed.isSet(field_7_option_flags));
    
public shortgetFirstCol()
get the logical col number for the first cell this row (0 based index)

return
col - the col number

        return field_2_first_col;
    
public booleangetFormatted()
get whether the row has been formatted (even if its got all blank cells)

return
formatted or not
see
#getOptionFlags()

        return formatted.isSet(field_7_option_flags);
    
public shortgetHeight()
get the height of the row

return
height of the row

        return field_4_height;
    
public shortgetLastCol()
get the logical col number for the last cell this row plus one (0 based index)

return
col - the last col number + 1

        return field_3_last_col;
    
public shortgetOptimize()
get whether to optimize or not (set to 0)

return
optimize (set to 0)

        return field_5_optimize;
    
public shortgetOptionFlags()
gets the option bitmask. (use the individual bit setters that refer to this method)

return
options - the bitmask

        return field_7_option_flags;
    
public shortgetOutlineLevel()
get the outline level of this row

return
ol - the outline level
see
#getOptionFlags()

        return outlineLevel.getShortValue(field_7_option_flags);
    
public intgetRecordSize()

        return 20;
    
public intgetRowNumber()
get the logical row number for this row (0 based index)

return
row - the row number

        return field_1_row_number;
    
public shortgetSid()

        return sid;
    
public shortgetXFIndex()
if the row is formatted then this is the index to the extended format record

see
org.apache.poi.hssf.record.ExtendedFormatRecord
return
index to the XF record or bogus value (undefined) if isn't formatted

        return field_8_xf_index;
    
public booleangetZeroHeight()
get whether or not to display this row with 0 height

return
- z height is zero or not.
see
#getOptionFlags()

        return zeroHeight.isSet(field_7_option_flags);
    
public booleanisInValueSection()

        return true;
    
public intserialize(int offset, byte[] data)

        LittleEndian.putShort(data, 0 + offset, sid);
        LittleEndian.putShort(data, 2 + offset, ( short ) 16);
        //LittleEndian.putShort(data, 4 + offset, getRowNumber());
        LittleEndian.putShort(data, 4 + offset, ( short ) getRowNumber());
        LittleEndian.putShort(data, 6 + offset, getFirstCol() == -1 ? (short)0 : getFirstCol());
        LittleEndian.putShort(data, 8 + offset, getLastCol() == -1 ? (short)0 : getLastCol());
        LittleEndian.putShort(data, 10 + offset, getHeight());
        LittleEndian.putShort(data, 12 + offset, getOptimize());
        LittleEndian.putShort(data, 14 + offset, field_6_reserved);
        LittleEndian.putShort(data, 16 + offset, getOptionFlags());

//    LittleEndian.putShort(data,18,getOutlineLevel());
        LittleEndian.putShort(data, 18 + offset, getXFIndex());
        return getRecordSize();
    
public voidsetBadFontHeight(boolean f)
set whether the font and row height are not compatible

param
f true if they aren't compatible (damn not logic)
see
#setOptionFlags(short)

        field_7_option_flags =
            badFontHeight.setShortBoolean(field_7_option_flags, f);
    
public voidsetColapsed(boolean c)
set whether or not to colapse this row

param
c - colapse or not
see
#setOptionFlags(short)

        field_7_option_flags = colapsed.setShortBoolean(field_7_option_flags,
                c);
    
public voidsetFirstCol(short col)
set the logical col number for the first cell this row (0 based index)

param
col - the col number

        field_2_first_col = col;
    
public voidsetFormatted(boolean f)
set whether the row has been formatted (even if its got all blank cells)

param
f formatted or not
see
#setOptionFlags(short)

        field_7_option_flags = formatted.setShortBoolean(field_7_option_flags,
                f);
    
public voidsetHeight(short height)
set the height of the row

param
height of the row

        field_4_height = height;
    
public voidsetLastCol(short col)
set the logical col number for the last cell this row (0 based index)

param
col - the col number

        field_3_last_col = col;
    
public voidsetOptimize(short optimize)
set whether to optimize or not (set to 0)

param
optimize (set to 0)

        field_5_optimize = optimize;
    
public voidsetOptionFlags(short options)
sets the option bitmask. (use the individual bit setters that refer to this method)

param
options - the bitmask

        field_7_option_flags = options;
    
public voidsetOutlineLevel(short ol)
set the outline level of this row

param
ol - the outline level
see
#setOptionFlags(short)

        field_7_option_flags =
            outlineLevel.setShortValue(field_7_option_flags, ol);
    
public voidsetRowNumber(int row)
set the logical row number for this row (0 based index)

param
row - the row number

        field_1_row_number = row;
    
public voidsetXFIndex(short index)
if the row is formatted then this is the index to the extended format record

see
org.apache.poi.hssf.record.ExtendedFormatRecord
param
index to the XF record

        field_8_xf_index = index;
    
public voidsetZeroHeight(boolean z)
set whether or not to display this row with 0 height

param
z height is zero or not.
see
#setOptionFlags(short)

        field_7_option_flags =
            zeroHeight.setShortBoolean(field_7_option_flags, z);
    
public java.lang.StringtoString()

        StringBuffer buffer = new StringBuffer();

        buffer.append("[ROW]\n");
        buffer.append("    .rownumber      = ")
            .append(Integer.toHexString(getRowNumber())).append("\n");
        buffer.append("    .firstcol       = ")
            .append(Integer.toHexString(getFirstCol())).append("\n");
        buffer.append("    .lastcol        = ")
            .append(Integer.toHexString(getLastCol())).append("\n");
        buffer.append("    .height         = ")
            .append(Integer.toHexString(getHeight())).append("\n");
        buffer.append("    .optimize       = ")
            .append(Integer.toHexString(getOptimize())).append("\n");
        buffer.append("    .reserved       = ")
            .append(Integer.toHexString(field_6_reserved)).append("\n");
        buffer.append("    .optionflags    = ")
            .append(Integer.toHexString(getOptionFlags())).append("\n");
        buffer.append("        .outlinelvl = ")
            .append(Integer.toHexString(getOutlineLevel())).append("\n");
        buffer.append("        .colapsed   = ").append(getColapsed())
            .append("\n");
        buffer.append("        .zeroheight = ").append(getZeroHeight())
            .append("\n");
        buffer.append("        .badfontheig= ").append(getBadFontHeight())
            .append("\n");
        buffer.append("        .formatted  = ").append(getFormatted())
            .append("\n");
        buffer.append("    .xfindex        = ")
            .append(Integer.toHexString(getXFIndex())).append("\n");
        buffer.append("[/ROW]\n");
        return buffer.toString();
    
protected voidvalidateSid(short id)

        if (id != sid)
        {
            throw new RecordFormatException("NOT A valid ROW RECORD");
        }