if (row != null) {
if (wholeRow) {
if (resetOriginalRowHeight) {
row.setHeight((short)-1); //default height
}
new HSSFRowHelper(row).removeAllCells();
} else {
removeCells(row, lCol, rCol);
}
}
continue;
}
HSSFRow row2Replace = getRow( rowNum + n );
if (row != null) {
if ( row2Replace == null )
row2Replace = createRow( rowNum + n );
// Remove all the old cells from the row we'll
// be writing too, before we start overwriting
// any cells. This avoids issues with cells
// changing type, and records not being correctly
// overwritten
if (wholeRow) {
new HSSFRowHelper(row2Replace).removeAllCells();
} else {
removeCells(row2Replace, lCol, rCol);
}
} else {
// If this row doesn't exist, shall also remove
// the empty destination row
if (row2Replace != null) {
if (wholeRow) {
removeRow(row2Replace);
} else {
removeCells(row2Replace, lCol, rCol);
}
}
continue; // Nothing to do for this row
}
// Fix up row heights if required
if (wholeRow) {
if (copyRowHeight) {
row2Replace.setHeight(row.getHeight());
}
if (resetOriginalRowHeight) {
row.setHeight((short)0xff);
}
}
// Copy each cell from the source row to
// the destination row
if (wholeRow) {
for(Iterator<Cell> cells = row.cellIterator(); cells.hasNext(); ) {
HSSFCell cell = (HSSFCell)cells.next();
row.removeCell( cell );
CellValueRecordInterface cellRecord = new HSSFCellHelper(cell).getCellValueRecord();
cellRecord.setRow( rowNum + n );
new HSSFRowHelper(row2Replace).createCellFromRecord( cellRecord );
_helper.getInternalSheet().addValueRecord( rowNum + n, cellRecord );
}
// Now zap all the cells in the source row
new HSSFRowHelper(row).removeAllCells();
} else {
final int startCol = Math.max(row.getFirstCellNum(), lCol);
final int endCol = Math.min(row.getLastCellNum(), rCol);
for(int col = startCol; col <= endCol; ++col) {
HSSFCell cell = (HSSFCell)row.getCell(col);
if (cell == null) {
continue;
}
row.removeCell( cell );
CellValueRecordInterface cellRecord = new HSSFCellHelper(cell).getCellValueRecord();
cellRecord.setRow( rowNum + n );
new HSSFRowHelper(row2Replace).createCellFromRecord( cellRecord );
_helper.getInternalSheet().addValueRecord( rowNum + n, cellRecord );
}
// Now zap the cells in the source row
removeCells(row, lCol, rCol);
}