how to convert .csv to .xls file

i try use jxl API to read .csv file and wite to excel file

but it show the error ...

====================================

ScanFileError = jxl.read.biff.BiffException: Unable to recognize OLE stream

====================================

who can tell me how to solve the problem

thanks.....

[330 byte] By [yuninga] at [2007-10-2 22:01:25]
# 1
The exception suggests that the reader expects a binary file not a textual cvs one.
BIJ001a at 2007-7-14 1:17:42 > top of Java-index,Java Essentials,Java Programming...
# 2

Hi,

First thing, please change the subject as it is not related to what you asked.

You are getting unable to recognise OLE stream error when the form has elements other that <input type ="file">. You can solve this by any of the three methods like

1) // strip off the HTTP information from input stream

// for ex if the first four lines are request junk then in servlet include the code

bytesRead = is.readLine(junk, 0, junk.length);

bytesRead = is.readLine(junk, 0, junk.length);

bytesRead = is.readLine(junk, 0, junk.length);

bytesRead = is.readLine(junk, 0, junk.length);

2)Remove all of the other form elements from the upload form except the file element

3)Use the commons upload package from Jakarta to handle the multipart/form-data and include the code given below

boolean isMultipart = FileUpload.isMultipartContent(req);

if(isMultipart){

System.out.println("is MultiPart");

DiskFileUpload upload = new DiskFileUpload();

List fileList = upload.parseRequest(req);

Iterator iter = fileList.iterator();

FileItem item = (FileItem) iter.next();

if (!item.isFormField()) {

//it is other form elements

}

else{

//it is input type="file"

}

}

Note:apache POI package will be a better API than jxl for excel reading and writing.

Noufal_ka at 2007-7-14 1:17:42 > top of Java-index,Java Essentials,Java Programming...
# 3
> e:apache POI package will be a better API than jxl> for excel reading and writing.I beg to differ, jxl supports BIFF7, and is much smarter about cell contents(such as a date cell), and formulas.
sophisticatedda at 2007-7-14 1:17:42 > top of Java-index,Java Essentials,Java Programming...
# 4
I agree with the sophis....u cant blindly support POI..rgdsshanu
mshanua at 2007-7-14 1:17:42 > top of Java-index,Java Essentials,Java Programming...
# 5
Hi Shanu and Sophis,I posted something, but reverted. I'll make the things sure and will re postThanksNoufal
Noufal_ka at 2007-7-14 1:17:42 > top of Java-index,Java Essentials,Java Programming...
# 6

Hi Shanu and Sophis,

Im not well read enough to start an argument. I ve used jxl package and got the following exception

<Jun 13, 2006 6:33:16 AM EDT> <Error> <HTTP> <BEA-101017> <[ServletContext(id=82540369,name=ces,context-path=/CES/CES)] Root cause of ServletException.

java.lang.NoClassDefFoundError: common/Assert

at jxl.read.biff.SSTRecord.getString(I)Ljava/lang/String;(SSTRecord.java:417)

at jxl.read.biff.LabelSSTRecord.<init>(Ljxl/read/biff/Record;Ljxl/read/biff/SSTRecord;Ljxl/biff/FormattingRecords;Ljxl/read/biff/SheetImpl;)V(LabelSSTRecord.java:56)

at jxl.read.biff.SheetReader.read()V(SheetReader.java:270)

at jxl.read.biff.SheetImpl.readSheet()V(SheetImpl.java:611)

at jxl.read.biff.WorkbookParser.getSheet(I)Ljxl/Sheet;(WorkbookParser.java:197)

at com.lehman.cad.gc.approvals.cescore.CescoreUploadServlet.doPost(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V(CescoreUploadServlet.java:117)

at javax.servlet.http.HttpServlet.service(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V(HttpServlet.java:853)

at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava/lang/Object;(ServletStubImpl.java:996)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Lweblogic/servlet/internal/FilterChainImpl;)V(ServletStubImpl.java:419)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V(ServletStubImpl.java:315)

at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run()Ljava/lang/Object;(WebAppServletContext.java:6452)

at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic/security/subject/AbstractSubject;Ljava/security/PrivilegedAction;)Ljava/lang/Object;(AuthenticatedSubject.java:321)

at weblogic.security.service.SecurityManager.runAs(Lweblogic/security/acl/internal/AuthenticatedSubject;Lweblogic/security/acl/internal/AuthenticatedSubject;Ljava/security/PrivilegedAction;)Ljava/lang/Object;(SecurityManager.java:118)

at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic/servlet/internal/ServletRequestImpl;Lweblogic/servlet/internal/ServletResponseImpl;)V(WebAppServletContext.java:3661)

at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic/kernel/ExecuteThread;)V(ServletRequestImpl.java:2630)

at weblogic.kernel.ExecuteThread.execute(Lweblogic/kernel/ExecuteRequest;)V(ExecuteThread.java:219)

at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178)

at java.lang.Thread.startThreadFromVM(Ljava/lang/Thread;)V(Unknown Source)

if you people can solve this I'll agree with you that jxl is much smarter. one jar file which contains that class might solve the problem, but i did search for that and was left unsuccessful. An API without a proper documentation or user guide, is that what you suggest to people seeking advice? Please dont argue for the sake of it, instead give the proper directions to the community seeking advice which includes me

Thanks

Noufal

Noufal_ka at 2007-7-14 1:17:42 > top of Java-index,Java Essentials,Java Programming...