Missing EXCEL_95 type in FileFormatUtil.saveFormatToExtension

Hi,
Aspose cell has a bug in Excel 23.7, and an early version in the following function:

" public static String saveFormatToExtension(int format) ".

when we work with excel 95 files and use;

     int fileFormat = book.getFileFormat();
     excel 95 number is 22, but the return format from - saveFormatToExtension(int format) is null, as it is missing in the switch case. Can you please add Excel 95 to the switch case?

One more request: the OTS format is missing ether. The aspose cell recognizes it as 55 can you add him two to the switch case in saveFormatToExtension?

@paveln1234
By creating sample files for testing, we can reproduce the issue. Discovering OTS and Excel 95 files will get incorrect values when calling FileFormatUtil.saveFormatToExtension method.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-45637

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@paveln1234
As an alternative, you can directly convert the file format to the file suffix. Please refer to the following sample code.

public static String fileFormatToExtension(int fileFormat)
{
    switch (fileFormat)
    {
        case FileFormatType.CSV:
            return ".csv";
        case FileFormatType.EXCEL_97_TO_2003:
        case FileFormatType.EXCEL_95:
            return ".xls";
        case FileFormatType.XLSX:
            return ".xlsx";
        case FileFormatType.XLSB:
            return ".xlsb";
        case FileFormatType.XLSM:
            return ".xlsm";
        case FileFormatType.XLTM:
            return ".xltm";
        case FileFormatType.XLTX:
            return ".xltx";
        case FileFormatType.XLAM:
            return ".xlam";
        case FileFormatType.XML:
        case FileFormatType.SPREADSHEET_ML:
            return ".xml";
        case FileFormatType.HTML:
            return ".html";
        case FileFormatType.M_HTML:
            return ".mhtml";
        case FileFormatType.ODS:
        	return ".ods";
        case FileFormatType.OTS:
        	return ".ots";
        case FileFormatType.SXC:
            return ".sxc";
        case FileFormatType.FODS:
            return ".fods";
        case FileFormatType.TIFF:
            return ".tiff";
        case FileFormatType.BMP:
            return ".bmp";
        case FileFormatType.WMF:
            return ".wmf";
        case FileFormatType.EMF:
            return ".emf";
        case FileFormatType.JPG:
            return ".jpg";
        case FileFormatType.PNG:
            return ".png";
        case FileFormatType.GIF:
            return ".gif";
        case FileFormatType.DIF:
            return ".dif";
        case FileFormatType.DOC:
            return ".doc";
        case FileFormatType.DOCX:
            return ".docx";
        case FileFormatType.EPUB:
            return ".epub";
        case FileFormatType.G_ZIP:
            return ".gzip";
        case FileFormatType.XPS:
            return ".xps";
        //add other formats
        default:
            break;
    }
    return "";

}

Hope helps a bit.

@paveln1234,

This is to inform you that your issue (logged earlier as “CELLSJAVA-45637”) has been resolved in the APIs. The fix will be included in our upcoming release version (Aspose.Cells v23.10) scheduled for release in first half of October 2023. We will let you know when the next release is published.

Thank you for the quick solution.

@paveln1234,

You are welcome.

The issues you have found earlier (filed as CELLSJAVA-45637) have been fixed in Aspose.Cells for Java 23.10.

Hey @John.He @amjad.sahi,

As previously informed, the issue was expected to be resolved in Aspose.Cells for Java version 23.10. However, I am still encountering the problem in Aspose 24.1 and Aspose 23.11.

@vivekk930703
Hi, I use version 24.2 to test the following code(
2testfiles.7z (6.9 KB)

)

 Workbook book = new Workbook("a_95.xls");
 int format = book.getFileFormat();
 System.out.println("fileformat: " + format);
 format = FileFormatUtil.fileFormatToSaveFormat(format);
 System.out.println("saveformat: " + format);
 String formatStr = FileFormatUtil.saveFormatToExtension(format);
 System.out.println("excel95: " + formatStr);

 book = new Workbook("a_ots.ots");
 format = book.getFileFormat();
 System.out.println("fileformat: " + format);
 format = FileFormatUtil.fileFormatToSaveFormat(format);

 System.out.println("saveformat: " + format);
 formatStr = FileFormatUtil.saveFormatToExtension(format);
 System.out.println("ots: " + formatStr);

The result is as follows:
fileformat: 22
saveformat: 5
excel95: .xls
fileformat: 55
saveformat: 31
ots: .ots
Please check.

@vivekk930703,

Could you please zip your files(XLS, OTS, etc.) and attach the zipped archive here. Also, share your sample (runnable) code that you are using. We will check your issue soon.

Hey @amjad.sahi @John.He @xinya.zhu ,

I had not been utilizing FileFormatUtil.fileFormatToSaveFormat(format) prior to invoking FileFormatUtil.saveFormatToExtension(format), resulting in a NULL extension. Now that I’ve made the correction, it’s functioning properly.

Thank you.

@vivekk930703,

Good to know that your issue is sorted out now. Please feel free to write back to us if you have further queries or comments.