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);
}
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;
}
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;
}
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());
}
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());
}
Aggregations