Opening Different Microsoft Excel Versions Files

Opening Files of Different Microsoft Excel Versions

An application often has to be able to open Microsoft Excel files created in different versions, for example, Microsoft Excel 95,97, or Microsoft Excel 2007/2010/2013/2016/2019 and Office 365 . You might need to load a file in any one of several formats, including XLS, XLSX, XLSM, XLSB, SpreadsheetML, TabDelimited or TSV, CSV, ODS and so on. Use the constructor, or specify the Workbook class' SetFileFormat method to specifies the format using the FileFormatType enumeration.

The FileFormatType enumeration contains many pre-defined file formats some of which are given below.

File Format Types Description
FileFormatType_CSV Represents a CSV file
FileFormatType_Excel97To2003 Represents an Excel 97 - 2003 file
FileFormatType_Xlsx Represents an Excel 2007/2010/2013/2016/2019 and Office 365 XLSX file
FileFormatType_Xlsm Represents an Excel 2007/2010/2013/2016/2019 and Office 365 XLSM file
FileFormatType_Xltx Represents an Excel 2007/2010/2013/2016/2019 and Office 365 template XLTX file
FileFormatType_Xltm Represents an Excel 2007/2010/2013/2016/2019 and Office 365 macro-enabled XLTM file
FileFormatType_Xlsb Represents an Excel 2007/2010/2013/2016/2019 and Office 365 binary XLSB file
FileFormatType_SpreadsheetML Represents a SpreadsheetML file
FileFormatType_Tsv Represents a Tab-separated values file
FileFormatType_TabDelimited Represents a Tab Delimited text file
FileFormatType_Ods Represents an ODS file
FileFormatType_Html Represents an HTML file
FileFormatType_MHtml Represents an MHTML file

Opening Microsoft Excel 95/5.0 Files

To open a Microsoft Excel 95/5.0 file, use LoadOptions and set the related attribute for the LoadOptions class for the template file to be loaded. A sample file for testing this feature can be downloaded from the following link:

Excel95 File

Aspose::Cells::Startup();
// Instantiate LoadOptions specified by the LoadFormat.
LoadOptions loadOptions(LoadFormat::Excel97To2003);
// Create a Workbook object and opening the file
Workbook wbExcel95(u"Excel95.xls", loadOptions);
//Show following message on console
std::cout << "Microsoft Excel 95/5.0 workbook opened successfully!" << std::endl;
Aspose::Cells::Cleanup();

Opening Microsoft Excel 97 - 2003 Files

To open a Microsoft Excel 97 - 2003 file, use LoadOptions and set the related attribute for the LoadOptions class for the template file to be loaded.

Aspose::Cells::Startup();
// Instantiate LoadOptions specified by the LoadFormat.
LoadOptions loadOptions(LoadFormat::Excel97To2003);
// Create a Workbook object and opening the file
Workbook wbExcel03(u"Excel03.xls", loadOptions);
//Show following message on console
std::cout << "Microsoft Excel 97 - 2003 workbook opened successfully!" << std::endl;
Aspose::Cells::Cleanup();

Opening Microsoft Excel 2007/2010/2013/2016/2019 and Office 365 XLSX Files

To open a Microsoft Excel 2007/2010/2013/2016/2019 and Office 365 format, that is, XLSX or XLSB, specify the file path. You can also use LoadOptions and set the related attribute/options of the LoadOptions class for the template file to be loaded.

Aspose::Cells::Startup();
// The path to the documents directory.
U16String dataDir = u"";
// Opening Microsoft Excel 2007 Xlsx Files
LoadOptions loadOptions(LoadFormat::Xlsx);
// Create a Workbook object and opening the file from its path
Workbook wbExcel07(dataDir + u"Input.xlsx", loadOptions);
//Show following message on console
std::cout << "Microsoft Excel 2007 - Office365 workbook opened successfully!" << std::endl;
Aspose::Cells::Cleanup();

Aspose.Cells also supports opening password-protected Microsoft Excel 2007, 2010, 2013, 2016, 2019, Office 365 files.