Bug 44461 - shiftRows don't copy the CellStyle
Summary: shiftRows don't copy the CellStyle
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-21 02:41 UTC by Sven Nissel
Modified: 2015-05-01 20:09 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Nissel 2008-02-21 02:41:51 UTC
If I use HSSFSheet#shiftRows() it will not copy the CellStyle of the row befor. 

I fix it very bad and slowly this way:
public void insertRowAfter(int rowNum) {
		HSSFRow row = sheet.getRow(rowNum);
		sheet.shiftRows(rowNum + 1, sheet.getLastRowNum(), 1, true, true);
		
		HSSFRow newRow = sheet.getRow(rowNum + 1);
		for (short i = 0; i <= row.getLastCellNum(); i++) {
			HSSFCell cell = row.getCell(i);
			HSSFCell newCell = newRow.getCell(i);
			if (cell != null) {
				if (newCell == null)
					newCell = newRow.createCell(i);
				newCell.setCellStyle(cell.getCellStyle());
			}
		}
	}

Is this a bug- or future- request?
Comment 1 Dominik Stadler 2015-05-01 20:09:29 UTC
A quick test showed that this seems to work correctly with the current version of POI, please try it again with at least POI 3.12beta1 and reopen this bug with some more information if it still does not work for you.