[Issues] aspose-cells convert error with some files

Hi Aspose Support Team,

We use aspose-cells to convert excel files to pdf format and got below issue:
com.aspose.cells.CellsException: This file’s format is not supported or you don’t specify a correct format.
Sample code:

final List<byte[]> bytes = new ArrayList<>();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Workbook workbook = null;
final PdfSaveOptions saveOptions = new PdfSaveOptions(SaveFormat.PDF);
workbook = new Workbook(inputStream);

notSupport.zip (490 Bytes)

Please refer excel file on notSupport.zip (attached) for sample.

Thanks

@slmspsvietnamvn,
This file does not seem to be an XLS file as if you open it with some text editor, it is simply a text file. When you open this file with MS Excel, it also raises exception. Hence it is not an issue with the Aspose.Cells library but file itself is not an Excel file. You may please verify it using some text editor at your end.

@slmspsvietnamvn,

We have evaluated your file further and found it is Tab Delimited file (which is saved as XLS). So, you have to specify relevant load options while instantiating/creating the Workbook object. Please change the following line of code:
i.e.,
workbook = new Workbook(inputStream);
with:
workbook = new Workbook(inputStream, new LoadOptions(LoadFormat.TAB_DELIMITED));
it will work fine as I tested.

Let us know if you still find any issue.

@Amjad_Sahi, @ahsaniqbalsidiqui,

I understood now. So we need to handle exception to cover these cases - CSV file with XLS extension and vice versa.

Thank you.

@slmspsvietnamvn,

Yes and you may use my suggested line of code to cope with it.

@Amjad_Sahi,

Okie, thank you.

@slmspsvietnamvn,

You are welcome.