Bug 43008 - HSSFCell.setCellNum() works incorrectly.
Summary: HSSFCell.setCellNum() works incorrectly.
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: All All
: P3 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-01 06:19 UTC by Bina Prieto
Modified: 2008-01-09 06:28 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bina Prieto 2007-08-01 06:19:27 UTC
 
Comment 1 Bina Prieto 2007-08-01 06:25:33 UTC
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
HSSFRow row = sheet.createRow((short) 0);
HSSFCell cell = row.createCell((short) 0);
cell.setCellNum((short) 1);
// I think that I have here the came cell as by cell reference
// but cell1 is null reference
HSSFCell cell1 = row.getCell((short) 1);
short cellNum = cell1.getCellNum();

Run this code. We've got NPE but I think that row.getCell((short) 1); operator
should return created cell because we chaged cell number (that means "column" 
number) and now created cell number is 1! row.getCell((short) 0) should return 
null now.
in cell.setCellNum((short) 1); operator.
Comment 2 Nick Burch 2008-01-09 06:28:59 UTC
HSSFCell.setCellNum() was really just setting things in the raw record, and not
touching the row, which is why you were seeing what you were

I've deprecated the method, and added a moveCell method to HSSFRow. That ought
to work as you'd expect. (It's in svn trunk now)