Olika sätt att öppna filer
Contents
[
Hide
]
Med Aspose.Cells är det möjligt att öppna filer, till exempel för att hämta data, eller att använda en designermall för att påskynda utvecklingsprocessen. Aspose.Cells kan öppna en rad olika filer, till exempel Microsoft Excel-kalkylblad (XLS, XLSX, XLSM, XLSB), CSV eller 071618344.
Öppna en fil via en sökväg
Utvecklare kan öppna en Microsoft Excel-fil med dess sökväg på den lokala datorn genom att ange den iIArbetsbokklass konstruktör. Skicka bara sökvägen i konstruktorn som sträng. Aspose.Cells kommer automatiskt att upptäcka filformatstypen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Create Workbook object from an Excel file path | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleExcelFile.xlsx"))); | |
//Show following message on console | |
Console::WriteLine(new String("Workbook opened successfully using file path.")); |
Öppna en fil med en Stream
Det är också möjligt att öppna en Excel-fil som en stream. För att göra det, använd en överbelastad version av konstruktorn som tarStrömobjekt som innehåller filen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Create a Stream object | |
intrusive_ptr<FileStream> fstream = new FileStream(dirPath->StringAppend(new String("sampleExcelFile.xlsx")), FileMode_Open); | |
//Create Workbook object from a Stream object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(fstream); | |
//Show following message on console | |
Console::WriteLine(new String("Workbook opened successfully using stream.")); | |
//Close the Stream object | |
fstream->Close(); |