Konvertera arbetsbok till JSON med C++
Contents
[
Hide
]
Aspose.Cells stödjer konvertering av en arbetsbok till JSON (JavaScript Object Notation).
Konvertera Excel-arbetsbok till JSON
API:et Aspose.Cells ger stöd för att konvertera kalkylblad till JSON-format. För att exportera arbetsboken till JSON, skicka SaveFormat::Json som andra parameter till Workbook::Save metoden. Du kan också använda JsonSaveOptions-klassen för att specificera ytterligare inställningar för export av arbetsbladet till JSON.
Följande kodexempel visar hur man exporterar det aktiva arbetsbladet till JSON med hjälp av SaveFormat::Json enum-medlem. Se koden för att konvertera källfilen till utdata JSON-fil som genereras av koden för referens.
#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();
}