Aspose cells for java cant read some xls files

aspose cells for java cant read the following xls file
bad1.xls.zip (9.2 KB)

I included the code and the exception
other xls and xlsx files work as expected

thanks
Dov
dov@datarails.com

Workbook workbook = null;
try {
workbook = new Workbook(filename);
} catch (Exception e) {
e.printStackTrace();
throw new CantReadFileException("error reading workbook " + e);
}

com.aspose.cells.CellsException: This file’s format is not supported or you don’t specify a correct format.
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at aspose.services.AsposeService.getWorkbook(AsposeService.java:31)
at aspose.services.AsposeService.convert(AsposeService.java:41)
at aspose.services.CMDhandler.handleCommands(CMDhandler.java:39)
at aspose.MainApplication.run(MainApplication.java:48)
at aspose.MainApplication.main(MainApplication.java:31)

@turaaa,

Thanks for the template file and sample code segment.

I checked your template XLS file which is an older format (“Microsoft Excel 5.0/95 Workbook”). The previous versions (before v19.1) do not support older file formats but latest version (i.e., Aspose.Cells for Java 19.1.x) does support Excel 5.0/95 XLS file format. Please try our latest version/fix: Aspose.Cells for Java v19.1.1 (attached)

It works fine with your attached file.

Let us know your feedback.
aspose-cells-19.1.1-java.zip (6.5 MB)

thanks for the response , the original xls file worked fine in 19.1,
however I have another xls file,“newbad” that doesnt work even in 19.6 .
when converting it from xls to xlsm the xlsm gets created with gibrish inside.

newbad.xls.zip (14.9 KB)

@turaaa,

Thanks for providing template file.

Good to know that your previous issue was fixed. Regarding your newer issue, I have checked your so called .xls file and found it is actually an HTML (“Web page”) file. Since it is not a native MS Excel file (XLS, XLSX), so Aspose.Cells thinks it is a txt file. The output file will have the exact source tags and data in it. Also, when you open the file into MS Excel, it prompts an error.

Please try the following sample code to convert your file to XLSM file format for your needs, I have tested using latest version and it works fine:
e.g
Sample code:

HTMLLoadOptions opts = new HTMLLoadOptions(LoadFormat.HTML);
        opts.setAutoFitColsAndRows(true);
        Workbook workbook = new Workbook("f:\\files\\newbad.xls", opts);
		workbook.save("f:\\files\\out1.xlsm", SaveFormat.XLSM);

Hope, this helps a bit.

thanks, this helped

@turaaa,

Good to know that your issue is sorted out by the suggested sample code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.