Class ExportRangeToJsonOptions

ExportRangeToJsonOptions class

Indicates the options that exporting range to json.

public class ExportRangeToJsonOptions

Constructors

NameDescription
ExportRangeToJsonOptions()The default constructor.

Properties

NameDescription
ExportAsString { get; set; }Exports the string value of the cells to json.
ExportEmptyCells { get; set; }Indicates whether exporting empty cells as null.
HasHeaderRow { get; set; }Indicates whether the range contains header row.
Indent { get; set; }Indicates the indent.

Examples

using System;
using System.IO;
using Aspose.Cells;
using Aspose.Cells.Utility;

namespace AsposeCellsExamples
{
    public class UtilityClassExportRangeToJsonOptionsDemo
    {
        public static void Run()
        {
            // Create a new workbook with sample data
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            
            // Add sample data to cells
            worksheet.Cells["A1"].PutValue("Name");
            worksheet.Cells["B1"].PutValue("Age");
            worksheet.Cells["A2"].PutValue("John");
            worksheet.Cells["B2"].PutValue(30);
            worksheet.Cells["A3"].PutValue("Alice");
            worksheet.Cells["B3"].PutValue(25);

            // Create export options
            var exportOptions = new ExportRangeToJsonOptions();
            
            // Export range to JSON
            var range = worksheet.Cells.CreateRange(0, 0, 3, 2);
            string jsonData = JsonUtility.ExportRangeToJson(range, exportOptions);

            // Output the JSON
            Console.WriteLine("Exported JSON:");
            Console.WriteLine(jsonData);
            
            // Save to file (optional)
            File.WriteAllText("exported_data.json", jsonData);
        }
    }
}

See Also