Diversi modi per aprire i file
Contents
[
Hide
]
Con Aspose.Cells è possibile aprire file, ad esempio per recuperare dati, oppure utilizzare un template designer per velocizzare il processo di sviluppo. Aspose.Cells può aprire una gamma di file diversi, come fogli di calcolo Excel Microsoft (XLS, XLSX, XLSM, XLSB), CSV o TabDelimited file.
Apertura di un file tramite un percorso
Gli sviluppatori possono aprire un file Excel Microsoft utilizzando il percorso del file sul computer locale specificandolo nelCartella di lavorocostruttore di classe. Basta passare il percorso nel costruttore come String. Aspose.Cells rileverà automaticamente il tipo di formato del file.
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.")); |
Apertura di un file utilizzando uno stream
È anche possibile aprire un file Excel come flusso. Per fare ciò, usa una versione sovraccaricata del costruttore che accetta ilFlussooggetto che contiene il file.
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(); |