java - file upload excel exception -


i have problem in uploading excel file, java code below

file newfile = new file("c:/sample.xls"); int firstcolno = 0; int row = 0; cell cell; workbook wb = workbook.getworkbook(newfile); sheet sheet = wb.getsheet(0);     (row = 1; row < 1005; row++) {         labelcell labelcell1 = sheet.findlabelcell("compound_id");             if (labelcell1 != null) {                 firstcolno = labelcell1.getcolumn();                 cell = sheet.getcell(firstcolno, row);                     if (cell.getcontents() != null && cell.getcontents().length() > 0) {                                            system.out.println(cell.getcontents());                 } else {                                         system.out.println("-");                                     }                                 }                             } 

when debug i'm getting exception

jxl.read.biff.biffexception: unable recognize ole stream     @ jxl.read.biff.compoundfile.<init>(compoundfile.java:116)     @ jxl.read.biff.file.<init>(file.java:127)     @ jxl.workbook.getworkbook(workbook.java:221)     @ jxl.workbook.getworkbook(workbook.java:198)     @ hello.fileuploadexample.dopost(fileuploadexample.java:63)     @ javax.servlet.http.httpservlet.service(httpservlet.java:641)     @ javax.servlet.http.httpservlet.service(httpservlet.java:722)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:225)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123)     @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:168)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:98)     @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:927)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1001)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:579)     @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1110)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:603)     @ java.lang.thread.run(thread.java:722) 

i'm using jxl.jar file file upload.

can me solve it?

on stacktrace

at jxl.workbook.getworkbook(workbook.java:198)

which called in code at

workbook wb = workbook.getworkbook(newfile); 

i have used poi , other excel library, not , seems @ point can filenotfoundexception converted jxl.read.biff.biffexception or library doesn't recognize input file format.- because gave plain.txt renamed .xls

pls verification @ least java level

if(!newfile.isfile()){     return; } 

also can check length not 0 , on.

maybe this can solution.

i hope helps find direction.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -