Libre is throwing error if .xls file is renamed to .xlsx

I am using the following command to to convert .xls file to pdf:

soffice.com --headless --convert-to pdf “D:\InputFiles\word2pdf\test.xls” --outdir D:\InputFiles\word2pdf

The above command is successfully converting that file to pdf. But when I am changing its extension to .xlsx and executing the same command getting an error.

Any idea why it is happening? Both files are opening in LibreOffice.

No way to tell for sure, when there’s no information in the question about LibreOffice version, nor the problematic file is available; but possibly related to LibreOffice 7.3 conversion tool can no longer convert .pptx to .html and tdf#148253 (may only be so if it’s in version 7.3; and if it is it, it’s fixed in upcoming 7.3.3).

We are using v7.2.5.2 of LibreOffice

Let’s try together with the attached file.
If everything is OK, then attach your file.
test.xlsx (8.0 KB)

The extensions does not fit to the file format. Why do you expect that it works?
I guess, you need to specify the input filter in case the extension does not fit to the file format. For input filter see File Conversion Filters Tables

3 Likes

Indeed - both extensions, as it turned out in tdf#148662.

As discovered in tdf#148662, @VkPatidar used some “3D .prt” file format (likely Unigraphics / Siemens NX), and renamed the files to XLS and XLSX, then tried to open these files and/or convert to PDF. Without describing the final result (which likely was garbage), the question was basically “why there is a difference, when the same garbage (from the program point of view) is processed without errors, when using one extension, but gives errors and is not processed using another”.

The technical reason it that there is a special condition for XLS extension in the code, caused by wide use of CSV files renamed to have XLS extension: every file with XLS extension, after usual detection fails, is opened using CSV import filter. Since CSV is a plain text format, it may open any file, just the result would be garbage.

On the other hand, there was no such abuse of XLSX extension, hence LibreOffice does not try to open such files as CSV. Usual detection fails (compound file is detected, but it’s not XLS), no CSV fallback happens, and the error is emitted.

Anyway, the behavior is OK - as @Regina told, “Why do you expect that it works?”. This is clear “garbage in, garbage out” case.

2 Likes