• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Text file xls to Binary format xls in Java.

 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi,

I have text format xls file. I want to read it through POI. POI needs file in binray format of xls rather than text format xls.
so, my question is how to convert text file format to binary format xls in Java.

Thank you,
Rahul
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XLS *is* a binary format, it is decidedly *not* a text format. So the question is: what kind of file have you got there? CSV?
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using COgnos SDK to generate XLS file. It's generate a XLS file but It's Save type is HTML and not Microsoft XLS. Hence My POI programs does not recognize the
XLS file and throws an exception.

Hope this helps.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's saved as HTML, then it's not XLS. You need to save it as XLS, or use a library that can read HTML.
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

May be I was not able to specify you properly. I create a excel file using cognos SDK. It creates .xls file but it's text xls file rather than binary xls file.
when I open the file and try to save as I se as as in attached snap shot.

Please take a look at it and let me know is there any way in java I can change the file type to "Microsoft Excel workbook option" after the file creation.

Thank you,
Rahul
saveAs.jpg
[Thumbnail for saveAs.jpg]
When I open excel and say save As it shows me this
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again: there is no such thing as a "text XLS" file. XLS is a binary format, period. It's possible that you have a file that has an .xls extension for some reason but which is not an XLS file. If that's the case, someone messed up. Then the question is: what's in the file? What you posted is a save dialog, it doesn't tell us anything about the file contents.
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yes, Contents of that file are same like other excel file

Please take a look at the following similar kind of problem

Click here
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it *is* an XLS file? So you just need to save it with a proper extension?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic