Convert Workbook to JSON with C++
Convert Excel Workbook to JSON
The Aspose.Cells API provides support for converting spreadsheets to JSON format. To export the workbook to JSON, pass SaveFormat::Json as the second parameter of the Workbook::Save method. You may also use the JsonSaveOptions class to specify additional settings for exporting the worksheet to JSON.
The following code example demonstrates exporting the active worksheet to JSON by using the SaveFormat::Json enumeration member. Please see the code to convert source file to the output JSON file generated by the code for reference.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
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 srcDir(u"..\\Data\\01_SourceDirectory\\");
// Path of input excel file
U16String inputFilePath = srcDir + u"Book1.xlsx";
// Create workbook
Workbook workbook(inputFilePath);
// Save the workbook as JSON
U16String outputFilePath = srcDir + u"book1.json";
workbook.Save(outputFilePath);
std::cout << "Workbook converted to JSON successfully!" << std::endl;
Aspose::Cells::Cleanup();
}