Bug 28749

Summary: Row number wraps on values greater than 65535
Product: POI Reporter: Conrad Roche <new_connie>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P3    
Version: 1.0.2   
Target Milestone: ---   
Hardware: Other   
OS: Windows XP   

Description Conrad Roche 2004-05-03 19:56:33 UTC
The row number wraps around for higher row numbers (>65535).
<code>
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("65536");

HSSFRow row = sheet.createRow((short)65536);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(65536);
</code>

The above code sets the value in the cell A1. 
[due to the cast (short)65536]

Shouldn't the behavior be similar to row.createCell((short)256) - which throws 
an exception? 

cheers
Conrad
Comment 1 Glen Stampoultzis 2004-09-21 12:58:59 UTC
In this case it seems that it's Java wrapping the value.

(short)256 = 256 because short is 16 bits.
(short)65536 = 0 because only the last 16 bits of the value are being used.

Comment 2 Jason Height 2006-07-24 12:42:30 UTC
Unless we change the API to use ints for the row numbers, this wont be fixed. 

As Glen points out this is a java vm behaviour.

Jason