Bug 19599 - java.lang.IllegalArgumentException
Summary: java.lang.IllegalArgumentException
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-pre3
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-02 15:55 UTC by David Parsons
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
source file that caused error...also found that it is an unsupported data cell_type (125.50 KB, application/octet-stream)
2003-05-06 18:16 UTC, David Parsons
Details
the input excel file (43.50 KB, excel/xls)
2003-05-13 04:55 UTC, james xu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Parsons 2003-05-02 15:55:08 UTC
This seems to be data-related...when I remove the cell containing 
the "C10...", it works fine.

java.lang.IllegalArgumentException: Cannot store a duplicate value ("C10, C17, 
C19-20, C24, C35, C44, C55, C75, C84, C96, C99-105, C147, C150") in this Map
	at org.apache.poi.util.BinaryTree.insertValue(BinaryTree.java:1395)
	at org.apache.poi.util.BinaryTree.put(BinaryTree.java:1580)
	at org.apache.poi.hssf.record.SSTRecord.processString
(SSTRecord.java:1033)
	at org.apache.poi.hssf.record.SSTRecord.manufactureStrings
(SSTRecord.java:960)
	at org.apache.poi.hssf.record.SSTRecord.processContinueRecord
(SSTRecord.java:592)
	at org.apache.poi.hssf.record.RecordFactory.createRecords
(RecordFactory.java:210)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:140)
	at com.we.indentedbom.POIExample.main(POIExample.java:40)


I'm trying to read the spreadsheet and it works fine except for the value I 
refer to above.  Below is the code I'm using to walk the worksheet.

public class POIExample {

    public static void main( String [] args ) {
        try {
        	boolean DEBUG = true;
			String workbook = null;
			String xlateTemplate = null;
        	if (args != null)
        	{
        		try
        		{
					workbook = args[0];
					xlateTemplate = args[1];
					System.out.println("workbook name: " + 
workbook + "     xlateTemplate: " + xlateTemplate);
					//POIFSFileSystem fs =	new 
POIFSFileSystem(new FileInputStream("c:/workbook.xls"));
					POIFSFileSystem fs =	new 
POIFSFileSystem(new FileInputStream("C:/orion/default-web-
app/secure/plants/customerboms/filtronics.xls"));

					HSSFWorkbook wb = new HSSFWorkbook(fs);
					HSSFSheet sheet = wb.getSheetAt(0);

					// Iterate over each row in the sheet
					Iterator rows = sheet.rowIterator(); 
					while( rows.hasNext() ) 
					{           
						HSSFRow row = (HSSFRow) 
rows.next();
						System.out.println( "----------
-----  Row #" + row.getRowNum() );
						short lastCell = 
row.getLastCellNum();
						for (short i=0;i<lastCell;i++) 
						{
							try
							{
								HSSFCell cell 
= row.getCell(i);
							
	System.out.println( "Cell #" + cell.getCellNum() );
								switch ( 
cell.getCellType() ) {
									case 
HSSFCell.CELL_TYPE_NUMERIC:
									
	System.out.println( "Number: " + cell.getNumericCellValue() );
									
	break;
									case 
HSSFCell.CELL_TYPE_STRING: 
									
	System.out.println( "String: " + cell.getStringCellValue().replace
(',', '_') );
									
	break;
								
	default:
									
	if(DEBUG)
									
	{
									
		//System.out.println( "unsuported sell type" );
									
	}
									
	break;
								}
							}
							catch
(NullPointerException npe)
							{
								if(DEBUG)
								
	System.out.println("Nullpointer Caught");
							}
						}
    
					}
        		}
        		catch(ArrayIndexOutOfBoundsException oob)
        		{
        			System.out.println("You must pass both the 
workbook and the template file.");
					System.err.println("You must pass both 
the workbook and the template file.");
        			oob.printStackTrace();
        		}
				
        	}
        	else
        	{
        		System.err.println("you must pass the workbook name to 
be formatted and teh temp");
        	}
        	
        	
            
        } catch ( IOException ex ) {
            ex.printStackTrace();
        }
    }
    
}
Comment 1 Avik Sengupta 2003-05-06 16:09:42 UTC
You need to attach a simple example workbook that exhibits this error. 
Comment 2 David Parsons 2003-05-06 18:16:48 UTC
Created attachment 6238 [details]
source file that caused error...also found that it is an unsupported data cell_type
Comment 3 james xu 2003-05-13 04:55:01 UTC
Created attachment 6337 [details]
the input excel file
Comment 4 james xu 2003-05-13 04:56:46 UTC
I have this problem too,the error message is:
Caused by: java.lang.IllegalArgumentException: Cannot store a duplicate value ("
ŽŸ") in this Map
        at org.apache.poi.util.BinaryTree.insertValue(BinaryTree.java:1395)
        at org.apache.poi.util.BinaryTree.put(BinaryTree.java:1580)
        at org.apache.poi.hssf.record.SSTRecord.processString(SSTRecord.java:103
3)
        at org.apache.poi.hssf.record.SSTRecord.manufactureStrings(SSTRecord.jav
a:960)
        at org.apache.poi.hssf.record.SSTRecord.fillFields(SSTRecord.java:818)
        at org.apache.poi.hssf.record.Record.fillFields(Record.java:142)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:104)
        at org.apache.poi.hssf.record.SSTRecord.<init>(SSTRecord.java:161)
        ... 11 more
Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: Una
ble to construct record instance, the following exception occured: null
        at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.j
ava:259)
        at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.
java:184)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:1
40)
        at cn.com.asb.fsms.utility.xlsGenerator.FillTemplateforCity(xlsGenerator
.java:189)
        at cn.com.asb.fsms.report.ReportGenerator.GenerateCityReport(ReportGener
ator.java:463)
        at cn.com.asb.fsms.report.ReportGenerator.Generator(ReportGenerator.java
:176)
        at cn.com.asb.fsms.report.ReportGenerator.main(ReportGenerator.java:305)

Press any key to continue...

This is a chinese Excel file,and the bookwork include 2 sheets,each sheet have 
a column filled "ŽŸ",and if I delete the columne "ŽŸ" in one sheet,it's ok!
Comment 5 Andy Oliver 2003-07-24 16:28:58 UTC
Is this still a problem in 2.0-pre2
Comment 6 Avik Sengupta 2003-10-28 11:00:23 UTC
Fixed in CVS. Testcase Added. Will go into 2.0RC1