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(); } } }
You need to attach a simple example workbook that exhibits this error.
Created attachment 6238 [details] source file that caused error...also found that it is an unsupported data cell_type
Created attachment 6337 [details] the input excel file
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!
Is this still a problem in 2.0-pre2
Fixed in CVS. Testcase Added. Will go into 2.0RC1