Hi,
I’m using Aspose.Cells to produce output based on an input file. The WorkbookDesigner.Workbook.Open() method takes a FileFormatType parameter. I’m wondering if there is a way to determine what FileFormatType I should be using for a given file automatically. I have access to the file name (including extension), and also the MIME type of the file (though I’m not sure how reliable the MIME information is, but it should suffice). Unfortunately, it seems that Aspose.Cells differentiates between different formats that have the same file extension and MIME type, for example: Excel 97 and Excel 2003 each have their own entry in FileFormatType, yet they both have a “.xls” extension and a MIME type of “application/vnd.ms-excel”. Is there any way for me to get the FileFormatType? Ideally, I’m looking for a method I can call in the Aspose library, but I haven’t seen any such function in the docs. I’ll look at external solutions if that’s the only way to go. My app is written in C++ and accessing the Aspose.Cells library via a COM wrapper I created, so I’ll also entertain C++ solutions in addition to C#. Thank you very much.
Hi,
Thanks for your inquiry.
Well, if the file is of Excel97-2003 file, you may use FileFormatType.Default or FileFormatType.Excel2003.
In the current version, FileFormatType.Excel97, FileFormatType.Excel2000, FileFormatType.ExcelXP, FileFormatType.ExcelXP and FileFormatType.Excel2003 work same. So, ideally, for manipulating xls files, you may skip to provide FileFormatType, Aspose.Cells will choose default file format type for the xls files.
Sample code:
//Instantiate the Workbook object
Workbook workbook = new Workbook();
//Open an excel file
workbook.Open("f:\\test\\Input.xls");
//........
//Do something for your requirements
//.........
//Save as the excel file
workbook.Save("f:\\test\\Output.xls");
Thank you.