use of org.apache.poi.hssf.record.aggregates.MergedCellsTable in project poi by apache.
the class InternalSheet method removeMergedRegion.
public void removeMergedRegion(int index) {
//safety checks
MergedCellsTable mrt = getMergedRecords();
if (index >= mrt.getNumberOfMergedRegions()) {
return;
}
mrt.remove(index);
}
use of org.apache.poi.hssf.record.aggregates.MergedCellsTable in project poi by apache.
the class InternalSheet method addMergedRegion.
public int addMergedRegion(int rowFrom, int colFrom, int rowTo, int colTo) {
// Validate input
if (rowTo < rowFrom) {
throw new IllegalArgumentException("The 'to' row (" + rowTo + ") must not be less than the 'from' row (" + rowFrom + ")");
}
if (colTo < colFrom) {
throw new IllegalArgumentException("The 'to' col (" + colTo + ") must not be less than the 'from' col (" + colFrom + ")");
}
MergedCellsTable mrt = getMergedRecords();
mrt.addArea(rowFrom, colFrom, rowTo, colTo);
return mrt.getNumberOfMergedRegions() - 1;
}
use of org.apache.poi.hssf.record.aggregates.MergedCellsTable in project poi by apache.
the class TestMergeCellsRecord method testMCTable_bug46009.
public void testMCTable_bug46009() {
MergedCellsTable mct = new MergedCellsTable();
List<Record> recList = new ArrayList<Record>();
CellRangeAddress[] cras = new CellRangeAddress[] { new CellRangeAddress(0, 0, 0, 3) };
recList.add(new MergeCellsRecord(cras, 0, 1));
RecordStream rs = new RecordStream(recList, 0);
mct.read(rs);
try {
mct.visitContainedRecords(dummyRecordVisitor);
} catch (ArrayStoreException e) {
throw new AssertionFailedError("Identified bug 46009");
}
}
use of org.apache.poi.hssf.record.aggregates.MergedCellsTable in project poi by apache.
the class RecordOrderer method findInsertPosForNewCondFormatTable.
/**
* Find correct position to add new CFHeader record
*/
private static int findInsertPosForNewCondFormatTable(List<RecordBase> records) {
for (int i = records.size() - 2; i >= 0; i--) {
// -2 to skip EOF record
Object rb = records.get(i);
if (rb instanceof MergedCellsTable) {
return i + 1;
}
if (rb instanceof DataValidityTable) {
continue;
}
Record rec = (Record) rb;
switch(rec.getSid()) {
case WindowTwoRecord.sid:
case SCLRecord.sid:
case PaneRecord.sid:
case SelectionRecord.sid:
case UnknownRecord.STANDARDWIDTH_0099:
// MergedCellsTable usually here
case UnknownRecord.LABELRANGES_015F:
case UnknownRecord.PHONETICPR_00EF:
// ConditionalFormattingTable goes here
return i + 1;
}
}
throw new RuntimeException("Did not find Window2 record");
}
Aggregations