Methods Summary |
---|
public int | addArea(int rowfrom, short colfrom, int rowto, short colto)Add an area to consider a merged cell. The index returned is only gauranteed to
be correct provided you do not add ahead of or remove ahead of it (in which case
you should increment or decrement appropriately....in other words its an arrayList)
if (field_2_regions == null)
{
field_2_regions = new ArrayList(10);
}
MergedRegion region = new MergedRegion(rowfrom, rowto, colfrom,
colto);
field_2_regions.add(region);
return field_2_regions.size() - 1;
|
public java.lang.Object | clone()
MergeCellsRecord rec = new MergeCellsRecord();
rec.field_2_regions = new ArrayList();
Iterator iterator = field_2_regions.iterator();
while (iterator.hasNext()) {
MergedRegion oldRegion = (MergedRegion)iterator.next();
rec.addArea(oldRegion.row_from, oldRegion.col_from, oldRegion.row_to, oldRegion.col_to);
}
return rec;
|
protected void | fillFields(org.apache.poi.hssf.record.RecordInputStream in)
short numAreas = in.readShort();
field_2_regions = new ArrayList(numAreas + 10);
for (int k = 0; k < numAreas; k++)
{
MergedRegion region =
new MergedRegion(in.readShort(), in.readShort(),
in.readShort(), in.readShort());
field_2_regions.add(region);
}
|
public org.apache.poi.hssf.record.MergeCellsRecord$MergedRegion | getAreaAt(int index)return the MergedRegion at the given index.
return ( MergedRegion ) field_2_regions.get(index);
|
public short | getNumAreas()get the number of merged areas. If this drops down to 0 you should just go
ahead and delete the record.
//if the array size is larger than a short (65536), the record can't hold that many merges anyway
if (field_2_regions == null) return 0;
return (short)field_2_regions.size();
|
public int | getRecordSize()
int retValue;
retValue = 6 + (8 * field_2_regions.size());
return retValue;
|
public short | getSid()
return sid;
|
public void | removeAreaAt(int area)essentially unmerge the cells in the "area" stored at the passed in index
field_2_regions.remove(area);
|
public int | serialize(int offset, byte[] data)
int recordsize = getRecordSize();
int pos = 6;
LittleEndian.putShort(data, offset + 0, sid);
LittleEndian.putShort(data, offset + 2, ( short ) (recordsize - 4));
LittleEndian.putShort(data, offset + 4, getNumAreas());
for (int k = 0; k < getNumAreas(); k++)
{
MergedRegion region = getAreaAt(k);
//LittleEndian.putShort(data, offset + pos, region.row_from);
LittleEndian.putShort(data, offset + pos, ( short ) region.row_from);
pos += 2;
//LittleEndian.putShort(data, offset + pos, region.row_to);
LittleEndian.putShort(data, offset + pos, ( short ) region.row_to);
pos += 2;
LittleEndian.putShort(data, offset + pos, region.col_from);
pos += 2;
LittleEndian.putShort(data, offset + pos, region.col_to);
pos += 2;
}
return recordsize;
|
public void | setNumAreas(short numareas)set the number of merged areas. You do not need to call this if you use addArea,
it will be incremented automatically or decremented when an area is removed. If
you are setting this to 0 then you are a terrible person. Just remove the record.
(just kidding about you being a terrible person..hehe)
|
public java.lang.String | toString()
StringBuffer retval = new StringBuffer();
retval.append("[MERGEDCELLS]").append("\n");
retval.append(" .sid =").append(sid).append("\n");
retval.append(" .numregions =").append(getNumAreas())
.append("\n");
for (int k = 0; k < getNumAreas(); k++)
{
MergedRegion region = ( MergedRegion ) field_2_regions.get(k);
retval.append(" .rowfrom =").append(region.row_from)
.append("\n");
retval.append(" .colfrom =").append(region.col_from)
.append("\n");
retval.append(" .rowto =").append(region.row_to)
.append("\n");
retval.append(" .colto =").append(region.col_to)
.append("\n");
}
retval.append("[MERGEDCELLS]").append("\n");
return retval.toString();
|
protected void | validateSid(short id)
if (id != sid)
{
throw new RecordFormatException("NOT A MERGEDCELLS RECORD!! "
+ id);
}
|