You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2003/05/02 17:55:09 UTC

DO NOT REPLY [Bug 19599] New: - java.lang.IllegalArgumentException

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19599>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19599

java.lang.IllegalArgumentException

           Summary: java.lang.IllegalArgumentException
           Product: POI
           Version: 1.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: b2n2zjm@yahoo.com


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();
        }
    }
    
}