• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Text file xls to Binary format xls in Java.

 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So it *is* an XLS file? So you just need to save it with a proper extension?
 
reply
    Bookmark Topic Watch Topic
  • New Topic