Search in sources :

Example 1 with MergedCellsTable

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);
}
Also used : MergedCellsTable(org.apache.poi.hssf.record.aggregates.MergedCellsTable)

Example 2 with MergedCellsTable

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;
}
Also used : MergedCellsTable(org.apache.poi.hssf.record.aggregates.MergedCellsTable)

Example 3 with MergedCellsTable

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");
    }
}
Also used : MergedCellsTable(org.apache.poi.hssf.record.aggregates.MergedCellsTable) RecordStream(org.apache.poi.hssf.model.RecordStream) ArrayList(java.util.ArrayList) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) AssertionFailedError(junit.framework.AssertionFailedError)

Example 4 with MergedCellsTable

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");
}
Also used : MergedCellsTable(org.apache.poi.hssf.record.aggregates.MergedCellsTable) DrawingSelectionRecord(org.apache.poi.hssf.record.DrawingSelectionRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) ArrayRecord(org.apache.poi.hssf.record.ArrayRecord) DefaultColWidthRecord(org.apache.poi.hssf.record.DefaultColWidthRecord) DateWindow1904Record(org.apache.poi.hssf.record.DateWindow1904Record) DefaultRowHeightRecord(org.apache.poi.hssf.record.DefaultRowHeightRecord) GridsetRecord(org.apache.poi.hssf.record.GridsetRecord) SCLRecord(org.apache.poi.hssf.record.SCLRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) BoolErrRecord(org.apache.poi.hssf.record.BoolErrRecord) Record(org.apache.poi.hssf.record.Record) HyperlinkRecord(org.apache.poi.hssf.record.HyperlinkRecord) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) PrintHeadersRecord(org.apache.poi.hssf.record.PrintHeadersRecord) RefModeRecord(org.apache.poi.hssf.record.RefModeRecord) PrecisionRecord(org.apache.poi.hssf.record.PrecisionRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) CalcCountRecord(org.apache.poi.hssf.record.CalcCountRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) PrintGridlinesRecord(org.apache.poi.hssf.record.PrintGridlinesRecord) IterationRecord(org.apache.poi.hssf.record.IterationRecord) CalcModeRecord(org.apache.poi.hssf.record.CalcModeRecord) SelectionRecord(org.apache.poi.hssf.record.SelectionRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) LabelSSTRecord(org.apache.poi.hssf.record.LabelSSTRecord) RKRecord(org.apache.poi.hssf.record.RKRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) LabelRecord(org.apache.poi.hssf.record.LabelRecord) DVALRecord(org.apache.poi.hssf.record.DVALRecord) WindowOneRecord(org.apache.poi.hssf.record.WindowOneRecord) DeltaRecord(org.apache.poi.hssf.record.DeltaRecord) PaneRecord(org.apache.poi.hssf.record.PaneRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) FeatRecord(org.apache.poi.hssf.record.FeatRecord) ViewDefinitionRecord(org.apache.poi.hssf.record.pivottable.ViewDefinitionRecord) SaveRecalcRecord(org.apache.poi.hssf.record.SaveRecalcRecord) TableRecord(org.apache.poi.hssf.record.TableRecord) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) DataValidityTable(org.apache.poi.hssf.record.aggregates.DataValidityTable)

Aggregations

MergedCellsTable (org.apache.poi.hssf.record.aggregates.MergedCellsTable)3 ArrayList (java.util.ArrayList)1 AssertionFailedError (junit.framework.AssertionFailedError)1 RecordStream (org.apache.poi.hssf.model.RecordStream)1 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BlankRecord (org.apache.poi.hssf.record.BlankRecord)1 BoolErrRecord (org.apache.poi.hssf.record.BoolErrRecord)1 CalcCountRecord (org.apache.poi.hssf.record.CalcCountRecord)1 CalcModeRecord (org.apache.poi.hssf.record.CalcModeRecord)1 ColumnInfoRecord (org.apache.poi.hssf.record.ColumnInfoRecord)1 DVALRecord (org.apache.poi.hssf.record.DVALRecord)1 DateWindow1904Record (org.apache.poi.hssf.record.DateWindow1904Record)1 DefaultColWidthRecord (org.apache.poi.hssf.record.DefaultColWidthRecord)1 DefaultRowHeightRecord (org.apache.poi.hssf.record.DefaultRowHeightRecord)1 DeltaRecord (org.apache.poi.hssf.record.DeltaRecord)1 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)1 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)1 DrawingSelectionRecord (org.apache.poi.hssf.record.DrawingSelectionRecord)1 EOFRecord (org.apache.poi.hssf.record.EOFRecord)1