Search in sources :

Example 6 with DimensionsRecord

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

the class InternalSheet method addValueRecord.

/**
     * Adds a value record to the sheet's contained binary records
     * (i.e. LabelSSTRecord or NumberRecord).
     * <P>
     * This method is "loc" sensitive.  Meaning you need to set LOC to where you
     * want it to start searching.  If you don't know do this: setLoc(getDimsLoc).
     * When adding several rows you can just start at the last one by leaving loc
     * at what this sets it to.
     *
     * @param row the row to add the cell value to
     * @param col the cell value record itself.
     */
public void addValueRecord(int row, CellValueRecordInterface col) {
    if (log.check(POILogger.DEBUG)) {
        log.log(POILogger.DEBUG, "add value record  row" + row);
    }
    DimensionsRecord d = _dimensions;
    if (col.getColumn() >= d.getLastCol()) {
        d.setLastCol((short) (col.getColumn() + 1));
    }
    if (col.getColumn() < d.getFirstCol()) {
        d.setFirstCol(col.getColumn());
    }
    _rowsAggregate.insertCell(col);
}
Also used : DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord)

Example 7 with DimensionsRecord

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

the class InternalSheet method createDimensions.

/**
     * creates the Dimensions Record and sets it to bogus values (you should set this yourself
     * or let the high level API do it for you)
     */
private static DimensionsRecord createDimensions() {
    DimensionsRecord retval = new DimensionsRecord();
    retval.setFirstCol((short) 0);
    // one more than it is
    retval.setLastRow(1);
    retval.setFirstRow(0);
    // one more than it is
    retval.setLastCol((short) 1);
    return retval;
}
Also used : DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord)

Example 8 with DimensionsRecord

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

the class HSSFChart method createDimensionsRecord.

private DimensionsRecord createDimensionsRecord() {
    DimensionsRecord r = new DimensionsRecord();
    r.setFirstRow(0);
    r.setLastRow(31);
    r.setFirstCol((short) 0);
    r.setLastCol((short) 1);
    return r;
}
Also used : DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord)

Example 9 with DimensionsRecord

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

the class TestSheet method testUncalcSize_bug45066.

/**
	 * Prior to bug 45066, POI would get the estimated sheet size wrong
	 * when an <tt>UncalcedRecord</tt> was present.<p/>
	 */
@Test
public void testUncalcSize_bug45066() {
    List<Record> records = new ArrayList<Record>();
    records.add(BOFRecord.createSheetBOF());
    records.add(new UncalcedRecord());
    records.add(new DimensionsRecord());
    records.add(createWindow2Record());
    records.add(EOFRecord.instance);
    InternalSheet sheet = createSheet(records);
    // The original bug was due to different logic for collecting records for sizing and
    // serialization. The code has since been refactored into a single method for visiting
    // all contained records.  Now this test is much less interesting
    SizeCheckingRecordVisitor scrv = new SizeCheckingRecordVisitor();
    sheet.visitContainedRecords(scrv, 0);
    assertEquals(90, scrv.getTotalSize());
}
Also used : UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) ArrayList(java.util.ArrayList) StringRecord(org.apache.poi.hssf.record.StringRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) 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) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) Test(org.junit.Test)

Example 10 with DimensionsRecord

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

the class TestSheet method testMissingDims.

/**
	 * Some apps seem to write files with missing DIMENSION records.
	 * Excel(2007) tolerates this, so POI should too.
	 */
@Test
public void testMissingDims() {
    int rowIx = 5;
    int colIx = 6;
    NumberRecord nr = new NumberRecord();
    nr.setRow(rowIx);
    nr.setColumn((short) colIx);
    nr.setValue(3.0);
    List<Record> inRecs = new ArrayList<Record>();
    inRecs.add(BOFRecord.createSheetBOF());
    inRecs.add(new RowRecord(rowIx));
    inRecs.add(nr);
    inRecs.add(createWindow2Record());
    inRecs.add(EOFRecord.instance);
    InternalSheet sheet;
    try {
        sheet = createSheet(inRecs);
    } catch (RuntimeException e) {
        if ("DimensionsRecord was not found".equals(e.getMessage())) {
            throw new AssertionFailedError("Identified bug 46206");
        }
        throw e;
    }
    RecordCollector rv = new RecordCollector();
    sheet.visitContainedRecords(rv, rowIx);
    Record[] outRecs = rv.getRecords();
    assertEquals(8, outRecs.length);
    DimensionsRecord dims = (DimensionsRecord) outRecs[5];
    assertEquals(rowIx, dims.getFirstRow());
    assertEquals(rowIx, dims.getLastRow());
    assertEquals(colIx, dims.getFirstCol());
    assertEquals(colIx, dims.getLastCol());
}
Also used : RecordCollector(org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector) RowRecord(org.apache.poi.hssf.record.RowRecord) ArrayList(java.util.ArrayList) StringRecord(org.apache.poi.hssf.record.StringRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) 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) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Aggregations

DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)12 RowRecord (org.apache.poi.hssf.record.RowRecord)8 Test (org.junit.Test)8 BlankRecord (org.apache.poi.hssf.record.BlankRecord)7 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)7 ObjRecord (org.apache.poi.hssf.record.ObjRecord)7 Record (org.apache.poi.hssf.record.Record)7 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)7 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)6 BOFRecord (org.apache.poi.hssf.record.BOFRecord)6 ColumnInfoRecord (org.apache.poi.hssf.record.ColumnInfoRecord)6 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)6 EOFRecord (org.apache.poi.hssf.record.EOFRecord)6 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)6 GutsRecord (org.apache.poi.hssf.record.GutsRecord)6 IndexRecord (org.apache.poi.hssf.record.IndexRecord)6 MergeCellsRecord (org.apache.poi.hssf.record.MergeCellsRecord)6 NoteRecord (org.apache.poi.hssf.record.NoteRecord)6 NumberRecord (org.apache.poi.hssf.record.NumberRecord)6 StringRecord (org.apache.poi.hssf.record.StringRecord)6