For a programmer, who is trying to update XLSB files within C++ application, Aspose.Total for C++ API can help to automate the updating process. It’s a full package of different C++ libraries dealing multiple formats including Microsoft Excel documents. Aspose.Cells for C++ API that is part of Aspose.Total for C++ package makes this modifying process easy. Process of updating the XLSB document is simple by firstly accessing the sheet and then update cell value in excel using C++.
How to Update XLSB File in C++
- Load the XLSB file using CreateIWorkbook
- Access of relevant Worksheet using GetIWorksheets()->GetObjectByIndex(0) and relevant cell using GetICells()->GetObjectByIndex
- Insert new data in the accessed cell using PutValue method
- Save the file as .xlsb file using Save method by passing the file with path as the parameter
Modification Requirements
- For XLSB modification, following system requirements for Windows and Linux systems
- Install from command line as
nuget install Aspose.Total.Cpp
- Or via Package Manager Console of Visual Studio with
Install-Package Aspose.Total.Cpp
- Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads
Code - Update XLSB File in C++
StringPtr dirPath = new String("..\\Data\\sourcePath\\"); | |
StringPtr outPath = new String("..\\Data\\OutputPath\\"); | |
StringPtr srcCSV = dirPath->StringAppend(new String(L"srcFile.csv")); | |
StringPtr updatedCSV = outPath->StringAppend(new String(L"outReadWriteCSV.csv")); | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(srcCSV); | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
StringPtr strVal = cell->GetStringValue(); | |
StringPtr cellValue = new String("Cell Value: "); | |
Console::WriteLine(cellValue->StringAppend(strVal)); | |
cell = ws->GetICells()->GetObjectByIndex(new String("C4")); | |
intrusive_ptr<String> strValPtr = new String(strVal); | |
cell->PutValue(strValPtr); | |
wb->Save(updatedCSV, SaveFormat_CSV); |