Bug 28749 - Row number wraps on values greater than 65535
Summary: Row number wraps on values greater than 65535
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 1.0.2
Hardware: Other Windows XP
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-03 19:56 UTC by Conrad Roche
Modified: 2006-07-24 05:42 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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