XMLStreamException when trying to load XLSX

Hello,
I try to open an XLSX file and I get the following error:

java.lang.IllegalStateException: XMLStreamException: Unexpected character ‘s’ (code 115) in prolog; expected ‘<’

  • at [row,col {unknown-source}]: [1,2]*
  • at com.aspose.cells.b.a.h.j.a(Unknown Source)*
  • at com.aspose.cells.b.a.h.j.a(Unknown Source)*
  • at com.aspose.cells.b.a.h.j.k(Unknown Source)*
  • at com.aspose.cells.lv.I(Unknown Source)*
  • at com.aspose.cells.lv.a(Unknown Source)*
  • at com.aspose.cells.lr.d(Unknown Source)*
  • at com.aspose.cells.lr.b(Unknown Source)*
  • at com.aspose.cells.lr.r(Unknown Source)*
  • at com.aspose.cells.lr.a(Unknown Source)*
  • at com.aspose.cells.lq.a(Unknown Source)*
  • at com.aspose.cells.Workbook.a(Unknown Source)*
  • at com.aspose.cells.Workbook.a(Unknown Source)*
  • at com.aspose.cells.Workbook.(Unknown Source)*

    Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ‘s’ (code 115) in prolog; expected ‘<’
  • at [row,col {unknown-source}]: [1,2]*
  • at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)*
  • at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2017)*
  • at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1102)*
  • … 36 more*

The error appears to be random. The MS Excel tool can open it without any problems. If I make some changes in the file, Aspose might also be able to open it.

You can test with this basic fail_to_open.zip (149.2 KB)
sample code:
public class TestImp {
@Test
public void testImport() throws Exception {
Workbook wb = new Workbook(“c:\Downloads\fail_to_open.xlsx”);
}
}

Sample file is attached.
Please provide a workaround if possible.

Thank you…

@Asentinel,

Which version of the product you are using? Please try using our latest version/fix(attached)
Aspose_Cells_Java_v19.11.9.zip (6.7 MB)
I have tested using v19.11.9, it works fine and I do not find any exception using your sample code and template file.

Hello,

Thank you for your quick response.
I am using version 7.1.0. Unfortunatelly, upgrading to the latest version is not possible at this moment.

Could you please test also with this version and let me know your findings ?
Thank you.

@Asentinel,

We are very sorry but we cannot evaluate issues based on older version. Neither we can include any fixes in older versions, the fixes are based on latest APIs set. I am afraid, there is no alternative but to upgrade to latest version of the product.

Hi,
I understand that and I don’t request a fix. I just want to know the root cause of the error - specifically, what exactly is wrong with the provided XLS file.
This file is generated with the same Aspose.XLS library, so if you can point the error. then maybe I can either change the writer or the reader to avoid the error.

Thank you.

@Asentinel,

I am afraid, it is difficult to find out what’s wrong with the file and how to avoid it using the older version that you are using. Apparently it seems a bug in the older version for reading module (internal). Over the years we have enhanced the reading/writing modules to make the product more compact and feature rich APIs. Anyways, we will check if we could find something in the file which was causing the issue in the older version. We do not make any promise as we will just give a try on your demand.

Once we have an update on it, we will share it with you.

I appreciate the effort.
If this matters, the Aspose dependencies that we used are stax2-api-3.0.2.jar, woodstox-core-asl-4.1.1.jar and dom4j-1.6.1.jar.

Thanks.

@Asentinel,
Thank you for additional information. We are analysing the data and will share our feedback soon.

@Asentinel,

We have investigated using your template file and found your issue may be caused by the archived data of some entries. If you could remove the file “xl\worksheets\sheet12.xml” and then add it back to the archive, the file can be opened by v7.1.0.

Hope, this helps a bit.

I will look into it.
Thank you!

@Asentinel,

You are welcome.