Diverse modalità per aprire i file
Apertura di un file tramite un percorso
Gli sviluppatori possono aprire un file di Microsoft Excel utilizzando il percorso del file sul computer locale specificandolo nel costruttore della classe Workbook. Basta passare il percorso nel costruttore come String. Aspose.Cells rileverà automaticamente il tipo di formato del file.
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
Aspose::Cells::Startup(); | |
//Source directory path | |
U16String dirPath(u"..\\Data\\LoadingSavingAndConverting\\"); | |
//Create Workbook object from an Excel file path | |
Workbook workbook(dirPath + u"sampleExcelFile.xlsx"); | |
//Show following message on console | |
std::cout << "Workbook opened successfully using file path." << std::endl; | |
Aspose::Cells::Cleanup(); |
Apertura di un file utilizzando uno stream
È anche possibile aprire un file Excel come stream. Per farlo, utilizzare una versione sovraccaricata del costruttore che accetta l’oggetto Stream che contiene il file.
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
Aspose::Cells::Startup(); | |
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
U16String dirPath(u"..\\Data\\LoadingSavingAndConverting\\"); | |
//You need to write your own code to read the contents of the sampleExcelFile.xlsx file into this variable. | |
Vector<uint8_t> FileStream{ 0 }; //"sampleExcelFile.xlsx" | |
//Create Workbook object from a Stream object | |
Workbook workbook(FileStream); | |
//Show following message on console | |
std::cout << "Workbook opened successfully using stream." << std::endl; | |
Aspose::Cells::Cleanup(); |