Öppning av olika Microsoft Excel versioner filer

Öppning av filer av olika Microsoft Excel-versioner

En applikation måste ofta kunna öppna Microsoft Excel-filer skapade i olika versioner, till exempel Microsoft Excel 95,97 eller Microsoft Excel 2007/2010/2013/2016/2019 och Office 365. Du kan behöva ladda en fil i något av flera format, inklusive XLS, XLSX, XLSM, XLSB, SpreadsheetML, Tabulator-avgränsat eller TSV, CSV, ODS osv. Använd konstruktorn eller specificera Workbookklassens SetFileFormatmetod för att ange formatet med hjälp av FileFormatTypeuppräkningen.

FileFormatTypeuppräkningen innehåller många fördefinierade filformat varav några ges nedan.

Filtyp Beskrivning
FileFormatType_CSV Representerar en CSV-fil
FileFormatType_Excel97To2003 Representerar en Excel 97 - 2003 fil
FileFormatType_Xlsx Representerar en Excel 2007/2010/2013/2016/2019 och Office 365 XLSX-fil
FileFormatType_Xlsm Representerar en Excel 2007/2010/2013/2016/2019 och Office 365 XLSM-fil
FileFormatType_Xltx Representerar en Excel 2007/2010/2013/2016/2019 och Office 365 mall XLTX-fil
FileFormatType_Xltm Representerar en Excel 2007/2010/2013/2016/2019 och Office 365 makroaktiverad XLTM-fil
FileFormatType_Xlsb Representerar en Excel 2007/2010/2013/2016/2019 och Office 365 binär XLSB-fil
FileFormatType_SpreadsheetML Representerar en SpreadsheetML-fil
FileFormatType_Tsv Representerar en tabseparatorvärdesfil
FileFormatType_TabDelimited Representerar en flikskild textfil
FileFormatType_Ods Representerar en ODS-fil
FileFormatType_Html Representerar en HTML-fil
FileFormatType_MHtml Representerar en MHTML-fil

Öppna Microsoft Excel 95/5.0 Fil

För att öppna en Microsoft Excel 95/5.0 fil, använd LoadOptions och ställ in den relaterade attributen för LoadOptions-klassen för den mallfil som ska laddas. En provfil för att testa den här funktionen kan laddas ner från följande länk:

Excel95 fil

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

Öppna Microsoft Excel 97 - 2003 Fil

För att öppna en Microsoft Excel 97 - 2003 fil, använd LoadOptions och ställ in den relaterade attributen för LoadOptions-klassen för den mallfil som ska laddas.

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

Öppna Microsoft Excel 2007/2010/2013/2016/2019 och Office 365 XLSX Fil

För att öppna en Microsoft Excel 2007/2010/2013/2016/2019 och Office 365-format, dvs. XLSX eller XLSB, ange filvägen. Du kan också använda LoadOptions och ställa in den relaterade attributen/alternativen för klassen LoadOptions som ska laddas.

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 stöder också öppning av lösenordsskyddade Microsoft Excel 2007, 2010, 2013, 2016, 2019, Office 365 filer.