تحويل Excel إلى JSON باستخدام C++
Contents
[
Hide
]
تدعم Aspose.Cells تحويل دفتر العمل إلى ملف Json (كائن التبادل بيانات الجافا) .
تحويل دفتر العمل Excel إلى JSON
لا حاجة للقلق حول كيفية تحويل ملف Excel إلى JSON، لأن مكتبة Aspose.Cells for C++ تقدم أفضل الحلول. توفر API Aspose.Cells دعمًا لتحويل جداول البيانات إلى تنسيق JSON. لتصدير دفتر العمل إلى JSON، مرر SaveFormat.Json كوسيط ثانٍ لطريقة Workbook.Save. يمكنك أيضًا استخدام فئة JsonSaveOptions لتحديد إعدادات إضافية لتصدير ورقة العمل إلى JSON.
يعرض المثال البرمجي التالي تصدير دفتر عمل Excel إلى JSON. يرجى مراجعة الكود لتحويل الملف المصدر (sample.xlsx) إلى ملف JSON الناتج بواسطة الكود للمراجعة.
#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
// Load your source workbook
U16String inputFilePath(u"sample.xlsx");
Workbook workbook(inputFilePath);
// Convert the workbook to JSON file.
U16String outputFilePath(u"sample_out.json");
workbook.Save(outputFilePath, SaveFormat::Json);
std::cout << "Workbook converted to JSON successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
يوضح المثال البرمجي التالي الذي يستخدم فئة JsonLoadOptions لتحديد إعدادات إضافية تصدير دفتر عمل Excel إلى JSON. يرجى مراجعة الكود لتحويل الملف المصدر (sample.xlsx) إلى ملف JSON الناتج بواسطة الكود للمراجعة.
#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
// Create an options of saving the file.
JsonSaveOptions options;
// Set the exporting range.
options.SetExportArea(CellArea::CreateCellArea(u"B1", u"C4"));
// Load your source workbook
Workbook workbook(u"sample.xlsx");
// Convert the workbook to json file.
workbook.Save(u"sample_out.json", options);
std::cout << "Workbook successfully converted to JSON!" << std::endl;
Aspose::Cells::Cleanup();
}