Created attachment 25611 [details] This document throws throws RecordFormatException: Unable to construct record instance, while reading. Hi, I am trying to read a xls file which has images, radio buttons and dropdowns. While reading: InputStream input = new FileInputStream(parentDir + File.separator + "Temp" + File.separator + filename); wb = new HSSFWorkbook(input); It throws RecordFormatException as below: org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance at org.apache.poi.hssf.record.RecordFactory$ReflectionRecordCreator.create(RecordFactory.java:64) at org.apache.poi.hssf.record.RecordFactory.createSingleRecord(RecordFactory.java:263) at org.apache.poi.hssf.record.RecordFactoryInputStream.readNextRecord(RecordFactoryInputStream.java:270) at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:236) at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:392) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:276) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:201) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:317) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:298) at com.instasecure.apps.spreadsheet.SpreadsheetPOI.readWorkbook(SpreadsheetPOI.java:105) at com.instasecure.apps.spreadsheet.TransformSpreadSheet.transformOOToLDXml(TransformSpreadSheet.java:27) at com.instasecure.apps.spreadsheet.TransformSpreadSheet.transform(TransformSpreadSheet.java:12) at com.instasecure.util.openoffice.LocalOOAccess.transformSpreadSheet(LocalOOAccess.java:283) at com.instasecure.util.openoffice.LocalOOAccess.convert(LocalOOAccess.java:241) at com.instasecure.util.openoffice.LocalOOAccess.call(LocalOOAccess.java:78) at com.instasecure.util.openoffice.OOAccessHelper.call(OOAccessHelper.java:62) at com.instasecure.secure.DocumentSecuringHelper.saveSpreadSheetRelatedFiles(DocumentSecuringHelper.java:611) at com.instasecure.secure.DocumentSecuringHelper.saveDocRelatedFiles(DocumentSecuringHelper.java:185) at com.instasecure.secure.DocumentSecurer.secure(DocumentSecurer.java:164) at com.instasecure.command.DocumentSecureCmd.secureDocAndUpdateDB(DocumentSecureCmd.java:109) at com.instasecure.action.DocumentSecureAction.execute(DocumentSecureAction.java:112) at com.instasecure.action.InstaSecureAction.execute(InstaSecureAction.java:79) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at com.instasecure.requestprocessing.InstaSecureActionServlet.service(InstaSecureActionServlet.java:26) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.instasecure.requestprocessing.InstaSecureSessionFilter.doFilter(InstaSecureSessionFilter.java:141) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.instasecure.requestprocessing.AllowRequestFilter.doFilter(AllowRequestFilter.java:126) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.RuntimeException: Unexpected end-of-file at org.apache.poi.util.LittleEndianInputStream.checkEOF(LittleEndianInputStream.java:123) at org.apache.poi.util.LittleEndianInputStream.readUByte(LittleEndianInputStream.java:53) at org.apache.poi.util.LittleEndianInputStream.readByte(LittleEndianInputStream.java:44) at org.apache.poi.util.StringUtil.readUnicodeString(StringUtil.java:137) at org.apache.poi.hssf.record.LbsDataSubRecord$LbsDropData.<init>(LbsDataSubRecord.java:305) at org.apache.poi.hssf.record.LbsDataSubRecord.<init>(LbsDataSubRecord.java:127) at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:59) at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:96) at sun.reflect.GeneratedConstructorAccessor47.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.poi.hssf.record.RecordFactory$ReflectionRecordCreator.create(RecordFactory.java:56) ... 46 more Please help. I am also attaching the document for reference. Thanks & Regards, Pankaj Dubey Software Engineer Team Live Documents | InstaColl, Bangalore Contact: pankaj@instacoll.com | +91-9916129921
It looks like org.apache.poi.hssf.record.LbsDataSubRecord is expecting more data than exists in your file How was the file created? Excel or something else? If you load the file in excel, and "Save As", does the new file work with poi?
(In reply to comment #1) Hi Nick, Thanks for the prompt response. Actually, the file was created as XLS with MS Office. If we open the file with MS Office and then save it as XLSX and then again convert the XLSX file to XLS with open OpenOffice, the POI is having no issues in reading that document(XLS file). But POI is failing to read the document directly, as mentioned earlier. I am not able to understand why this is happening, There is no change in the document contents after saving it as XLS with OpenOffice. Thanks & Regards, Pankaj Dubey Software Engineer Team Live Documents | InstaColl, Bangalore Contact: pankaj@instacoll.com | +91-9916129921
I think you're going to need to do some investigating of LbsDataSubRecord You'll need to download the microsoft file format specs, and compare the data in your record with what the spec says should be there, and with what poi expects. The LbsDataSubRecord looks a little complicated (lots of bits that may or may not be there based on what else is there), so it's always possible that one of these clauses is missing Once you figure out the problem, do please report back / send in a patch!