0

I want to open a .xls file which not supported by Apache POI since the file is neither a .xls file nor a .xlsx one. If you open it in a text editor, you'll see that instead it's HTML! Please see https://bz.apache.org/bugzilla/show_bug.cgi?id=51031

As per the java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream

I also tried with jxl and it throws jxl.read.biff.BiffException: Unable to recognize OLE stream.

only way to bypass this is save it again ,since I 'am using an automation script can anyone suggest a walkaround .

Sameera De Silva
  • 1,722
  • 1
  • 22
  • 41
  • 2
    `Microsoft Excel` internally converts that `HTML`. But if a `*.xls` file contains `HTML`, `Excel` throws a warning while opening the file. It warns that file format and extension do not match. Only if you accept that warning message, it opens and converts the `HTML`. So having the case that a `*.xls` contains `HTML` is not good practice. – Axel Richter Feb 05 '20 at 06:11
  • @ Axel Richter Thank you for the suggestion ,but this application is belong to a third party company so unable to ask for a code modification. – Sameera De Silva Feb 05 '20 at 07:32
  • 2
    Then you need converting the `HTML` to a native `Excel` format first. `Apache poi` cannot do that for you. You could read the content out of the `HTML` using another library and then write a native `Excel` file from that content using `apache poi`. But doing the conversion exactly the same as `Excel` will do will be a very hard task. – Axel Richter Feb 05 '20 at 07:40

0 Answers0