| Method from org.apache.poi.hssf.usermodel.HSSFRow Detail: |
public Iterator cellIterator() {
return new CellIterator();
}
|
public int compareTo(Object obj) {
HSSFRow loc = (HSSFRow) obj;
if (this.getRowNum() == loc.getRowNum())
{
return 0;
}
if (this.getRowNum() < loc.getRowNum())
{
return -1;
}
if (this.getRowNum() > loc.getRowNum())
{
return 1;
}
return -1;
}
|
public HSSFCell createCell(short column) {
return this.createCell(column,HSSFCell.CELL_TYPE_BLANK);
}
Use this to create new cells within the row and return it.
The cell that is returned is a CELL_TYPE_BLANK. The type can be changed
either through calling setCellValue or setCellType. |
public HSSFCell createCell(short column,
int type) {
HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), column, type);
addCell(cell);
sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
return cell;
}
Use this to create new cells within the row and return it.
The cell that is returned is a CELL_TYPE_BLANK. The type can be changed
either through calling setCellValue or setCellType. |
protected HSSFCell createCellFromRecord(CellValueRecordInterface cell) {
HSSFCell hcell = new HSSFCell(book, sheet, getRowNum(), cell);
addCell(hcell);
// sheet.addValueRecord(getRowNum(),cell.getCellValueRecord());
return hcell;
}
create a high level HSSFCell object from an existing low level record. Should
only be called from HSSFSheet or HSSFRow itself. |
public boolean equals(Object obj) {
if (!(obj instanceof HSSFRow))
{
return false;
}
HSSFRow loc = (HSSFRow) obj;
if (this.getRowNum() == loc.getRowNum())
{
return true;
}
return false;
}
|
public HSSFCell getCell(short cellnum) {
int ushortCellNum = cellnum & 0x0000FFFF; // avoid sign extension
return getCell(ushortCellNum);
}
Get the hssfcell representing a given column (logical cell)
0-based. If you ask for a cell that is not defined then
you get a null, unless you have set a different
MissingCellPolicy on the base workbook.
Short method signature provided to retain binary
compatibility. |
public HSSFCell getCell(int cellnum) {
return getCell(cellnum, book.getMissingCellPolicy());
}
Get the hssfcell representing a given column (logical cell)
0-based. If you ask for a cell that is not defined then
you get a null, unless you have set a different
MissingCellPolicy on the base workbook. |
public HSSFCell getCell(int cellnum,
HSSFRow.MissingCellPolicy policy) {
HSSFCell cell = retrieveCell(cellnum);
if(policy == RETURN_NULL_AND_BLANK) {
return cell;
}
if(policy == RETURN_BLANK_AS_NULL) {
if(cell == null) return cell;
if(cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
return null;
}
return cell;
}
if(policy == CREATE_NULL_AS_BLANK) {
if(cell == null) {
return createCell((short)cellnum, HSSFCell.CELL_TYPE_BLANK);
}
return cell;
}
throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
}
Get the hssfcell representing a given column (logical cell)
0-based. If you ask for a cell that is not defined, then
your supplied policy says what to do |
public short getFirstCellNum() {
if (getPhysicalNumberOfCells() == 0)
return -1;
else
return row.getFirstCol();
}
get the number of the first cell contained in this row. |
public short getHeight() {
return row.getHeight();
}
get the row's height or ff (-1) for undefined/default-height in twips (1/20th of a point) |
public float getHeightInPoints() {
return (row.getHeight() / 20);
}
get the row's height or ff (-1) for undefined/default-height in points (20*getHeight()) |
public short getLastCellNum() {
if (getPhysicalNumberOfCells() == 0) {
return -1;
}
return row.getLastCol();
}
Gets the index of the last cell contained in this row PLUS ONE. The result also
happens to be the 1-based column number of the last cell. This value can be used as a
standard upper bound when iterating over cells:
short minColIx = row.getFirstCellNum();
short maxColIx = row.getLastCellNum();
for(short colIx=minColIx; colIx<maxColIx; colIx++) {
HSSFCell cell = row.getCell(colIx);
if(cell == null) {
continue;
}
//... do something with cell
}
|
protected int getOutlineLevel() {
return row.getOutlineLevel();
}
Returns the rows outline level. Increased as you
put it into more groups (outlines), reduced as
you take it out of them.
TODO - Should this really be public? |
public int getPhysicalNumberOfCells() {
int count=0;
for(int i=0;i< cells.length;i++)
{
if(cells[i]!=null) count++;
}
return count;
}
gets the number of defined cells (NOT number of cells in the actual row!).
That is to say if only columns 0,4,5 have values then there would be 3. |
public int getRowNum() {
return rowNum;
}
get row number this row represents |
protected RowRecord getRowRecord() {
return row;
}
get the lowlevel RowRecord represented by this object - should only be called
by other parts of the high level API |
public boolean getZeroHeight() {
return row.getZeroHeight();
}
get whether or not to display this row with 0 height |
public Iterator iterator() {
return cellIterator();
}
|
public void moveCell(HSSFCell cell,
short newColumn) {
// Ensure the destination is free
if(cells.length > newColumn && cells[newColumn] != null) {
throw new IllegalArgumentException("Asked to move cell to column " + newColumn + " but there's already a cell there");
}
// Check it's one of ours
if(! cells[cell.getCellNum()].equals(cell)) {
throw new IllegalArgumentException("Asked to move a cell, but it didn't belong to our row");
}
// Move the cell to the new position
// (Don't remove the records though)
removeCell(cell, false);
cell.updateCellNum(newColumn);
addCell(cell);
}
Moves the supplied cell to a new column, which
must not already have a cell there! |
public void removeCell(HSSFCell cell) {
if(cell == null) {
throw new IllegalArgumentException("cell must not be null");
}
removeCell(cell, true);
}
remove the HSSFCell from this row. |
public void setHeight(short height) {
// row.setOptionFlags(
row.setBadFontHeight(true);
row.setHeight(height);
}
set the row's height or set to ff (-1) for undefined/default-height. Set the height in "twips" or
1/20th of a point. |
public void setHeightInPoints(float height) {
// row.setOptionFlags(
row.setBadFontHeight(true);
row.setHeight((short) (height * 20));
}
set the row's height in points. |
public void setRowNum(int rowNum) {
if ((rowNum < 0) || (rowNum > RowRecord.MAX_ROW_NUMBER)) {
throw new IllegalArgumentException("Invalid row number (" + rowNum
+ ") outside allowable range (0.." + RowRecord.MAX_ROW_NUMBER + ")");
}
this.rowNum = rowNum;
if (row != null)
{
row.setRowNumber(rowNum); // used only for KEY comparison (HSSFRow)
}
}
set the row number of this row. |
public void setZeroHeight(boolean zHeight) {
row.setZeroHeight(zHeight);
}
set whether or not to display this row with 0 height |