We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Cells recognises Open Presentation format file as 'ods'

Hi
We are using Cells, Words and Slides to provide PDF document previews to our users.
Users upload a file and we use the following code to ask each library if it can convert a particular file. Here is the code we use in our CellsConverter class to see if Aspose.Cells will accept a file, before trying to convert it. We use similar code in our WordConverter and SlideConverter classes.



boolean canConvert(String filePath, String ouptPutFormat) {
try {
// these are aspose.cells classes
FileFormatInfo info = FileFormatUtil.detectFileFormat(getFilePathFromURI(from));
//returned info object has format ‘14’ for the attached file
// this can return null or throw exception if not valid
String ext = FileFormatUtil.loadFormatToExtension(info.getLoadFormat());
// the returned extension is ‘ods’
log.debug(“The document format is: {}”, ext);
if (isEmpty(ext)){
return false;
}
} catch (Exception e) {
log.warn(e.getMessage());
return false;
}
return true;// if no exception is thrown from Aspose and 'ext != null then yes, we can convert this file)
}

It seems generally that if trying to load a ‘wrong’ file - e.g. a spreadsheet into Aspose.Words for example, then this code either throws an exception or returns null, so we are using that to determine if the file can be read into Aspose or not.
This seems to work well for all the conversions we’ve tried so far ( .doc, .docx, .xls, .rtf, .txt, .csv, .ppt, .pptx)

However, when adding support for .odp files, we notice that Aspose.Cells recognises the attached file as .ods format, even though it is a presentation created in OpenOffice 4.1.2 on Windows and saved in .odp form.Is this an error on our part in the way we are using the API or is it a bug in Aspose.Cells to recognise the file as ‘ods’ format?

( I have checked that we’re importing the correct packages for each converter class)

Would we do better, instead of the above code, just to call new Document/Presentation/Spreadsheet(file) for each Aspose library and if it doesn’t throw an exception, to assume that that library can work with a file?
Are there any performance differences between using this code:

FileFormatInfo info = FileFormatUtil.detectFileFormat(getFilePathFromURI(from));
//returned info object has format ‘14’ for the attached file
// this generally seems to return null or throw exception if not valid
String ext = FileFormatUtil.loadFormatToExtension(info.getLoadFormat());

and

new Document/Presentation/Spreadsheet (file)

Thanks for you help and if anything isn’t clear please ask for more info.

Richard

Hi Richard,

Thank you for contacting Aspose support.

richard-11:

We are using Cells, Words and Slides to provide PDF document previews to our users.
Users upload a file and we use the following code to ask each library if it can convert a particular file. Here is the code we use in our CellsConverter class to see if Aspose.Cells will accept a file, before trying to convert it. We use similar code in our WordConverter and SlideConverter classes.



boolean canConvert(String filePath, String ouptPutFormat) {
try {
// these are aspose.cells classes
FileFormatInfo info = FileFormatUtil.detectFileFormat(getFilePathFromURI(from));
//returned info object has format ‘14’ for the attached file
// this can return null or throw exception if not valid
String ext = FileFormatUtil.loadFormatToExtension(info.getLoadFormat());
// the returned extension is ‘ods’
log.debug(“The document format is: {}”, ext);
if (isEmpty(ext)){
return false;
}
} catch (Exception e) {
log.warn(e.getMessage());
return false;
}
return true;// if no exception is thrown from Aspose and 'ext != null then yes, we can convert this file)
}

It seems generally that if trying to load a ‘wrong’ file - e.g. a spreadsheet into Aspose.Words for example, then this code either throws an exception or returns null, so we are using that to determine if the file can be read into Aspose or not.
This seems to work well for all the conversions we’ve tried so far ( .doc, .docx, .xls, .rtf, .txt, .csv, .ppt, .pptx)

However, when adding support for .odp files, we notice that Aspose.Cells recognises the attached file as .ods format, even though it is a presentation created in OpenOffice 4.1.2 on Windows and saved in .odp form.Is this an error on our part in the way we are using the API or is it a bug in Aspose.Cells to recognise the file as ‘ods’ format?

( I have checked that we’re importing the correct packages for each converter class)


I have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 8.7.0, and I am able to replicate the issue as mentioned above, that is; the FileFormatUtil.loadFormatToExtension method is identifying the ODP as ODS. We need to further investigate the matter, therefore I have logged this incident as CELLSJAVA-41714 in our bug tracking system. Please spare us little time to properly analyze the scenario to revert back with updates in this regard.

richard-11:

Would we do better, instead of the above code, just to call new Document/Presentation/Spreadsheet(file) for each Aspose library and if it doesn’t throw an exception, to assume that that library can work with a file?
Are there any performance differences between using this code:

FileFormatInfo info = FileFormatUtil.detectFileFormat(getFilePathFromURI(from));
//returned info object has format ‘14’ for the attached file
// this generally seems to return null or throw exception if not valid
String ext = FileFormatUtil.loadFormatToExtension(info.getLoadFormat());

and

new Document/Presentation/Spreadsheet (file)


Regarding your comments as quoted above, I can comment only on the behalf of Aspose.Cells APIs because you have posted the concerns in Aspose.Cells support forum. In order to give broader coverage to your inquiry, you should create a new thread in Aspose.Total support forum with precise question. In perspective of Aspose.Cells APIs, if you try to load the provided presentation file in an instance of Workbook, the latest version of the API will throw java.lang.NullPointerException. Same exception can also occur if the input document is of type spreadsheet (valid format) but corrupted therefore Aspose.Cells APIs have exposed separate classes and static methods to detect the format of a given file.

Hi,

Thanks for using Aspose.Cells.

It is to inform you that we have fixed your issue CELLSJAVA-41714 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

The issues you have found earlier (filed as CELLSJAVA-41714) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.