Öffnen von verschiedenen Microsoft Excel Versionen Dateien

Öffnen von Dateien verschiedener Microsoft Excel-Versionen

Eine Anwendung muss oft in der Lage sein, Microsoft Excel-Dateien in verschiedenen Versionen zu öffnen, z. B. Microsoft Excel 95, 97 oder Microsoft Excel 2007/2010/2013/2016/2019 und Office 365. Möglicherweise müssen Sie eine Datei in einem der verschiedenen Formate laden, darunter XLS, XLSX, XLSM, XLSB, SpreadsheetML, Tab-getrennt oder TSV, CSV, ODS und so weiter. Verwenden Sie den Konstruktor oder geben Sie die Methode der Klasse Workbook an, um das Format mit der SetFileFormat-Enumeration anzugeben.

Die FileFormatType-Enumeration enthält viele vordefinierte Dateiformate, von denen einige unten aufgeführt sind.

Dateiformat-Typen Beschreibung
FileFormatType_CSV Stellt eine CSV-Datei dar
FileFormatType_Excel97To2003 Stellt eine Excel 97 - 2003-Datei dar
FileFormatType_Xlsx Stellt eine Excel 2007/2010/2013/2016/2019 und Office 365 XLSX-Datei dar
FileFormatType_Xlsm Stellt eine Excel 2007/2010/2013/2016/2019 und Office 365 XLSM-Datei dar
FileFormatType_Xltx Stellt eine Excel 2007/2010/2013/2016/2019 und Office 365 Vorlage XLTX-Datei dar
FileFormatType_Xltm Stellt eine Excel 2007/2010/2013/2016/2019 und Office 365 makrofähige XLTM-Datei dar
FileFormatType_Xlsb Stellt eine Excel 2007/2010/2013/2016/2019 und Office 365 binäre XLSB-Datei dar
FileFormatType_SpreadsheetML Stellt eine SpreadsheetML-Datei dar
FileFormatType_Tsv Stellt eine durch Tabulatoren getrennte Werte-Datei dar
FileFormatType_TabDelimited Stellt eine Tabstopp-Delimited-Textdatei dar
FileFormatType_Ods Stellt eine ODS-Datei dar
FileFormatType_Html Stellt eine HTML-Datei dar
FileFormatType_MHtml Stellt eine MHTML-Datei dar

Öffnen von Microsoft Excel 95/5.0-Dateien

Um eine Microsoft Excel 95/5.0-Datei zu öffnen, verwenden Sie LoadOptions und legen das zugehörige Attribut für die LoadOptions-Klasse der zu ladenden Vorlagendatei fest. Eine Beispieldatei zur Überprüfung dieses Features können Sie von folgendem Link herunterladen:

Excel95-Datei

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();

Öffnen von Microsoft Excel 97 - 2003-Dateien

Um eine Microsoft Excel 97 - 2003-Datei zu öffnen, verwenden Sie LoadOptions und legen das zugehörige Attribut für die LoadOptions-Klasse der zu ladenden Vorlagendatei fest.

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();

Öffnen von Microsoft Excel 2007/2010/2013/2016/2019 und Office 365 XLSX-Dateien

Um ein Microsoft Excel 2007/2010/2013/2016/2019 und Office 365-Format zu öffnen, d.h. XLSX oder XLSB, geben Sie den Dateipfad an. Sie können auch LoadOptions verwenden und die zugehörigen Attribute/Optionen der LoadOptions-Klasse der zu ladenden Vorlagendatei festlegen.

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 unterstützt auch das Öffnen von passwortgeschützten Microsoft Excel 2007, 2010, 2013, 2016, 2019, Office 365-Dateien.