Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1d0b30c
Add example: load-an-xlsx-workbook-from-a-file-path-and-verify-succes…
agent-aspose-cells-examples May 18, 2026
66fe1d5
Add example: export-the-active-worksheet-of-the-loaded-workbook-to-js…
agent-aspose-cells-examples May 18, 2026
c5fc2b6
Add example: export-the-entire-workbook-to-json-with-column-headers-i…
agent-aspose-cells-examples May 18, 2026
80b3c9b
Add example: specify-a-custom-date-format-in-jsonsaveoptions-before-e…
agent-aspose-cells-examples May 18, 2026
5f66495
Add example: exclude-empty-rows-from-json-output-by-setting-jsonsaveo…
agent-aspose-cells-examples May 18, 2026
3b6e02d
Add example: convert-a-json-file-containing-tabular-data-to-csv-using…
agent-aspose-cells-examples May 18, 2026
58a8ee8
Add example: define-a-semicolon-as-csv-delimiter-in-jsonlayoutoptions…
agent-aspose-cells-examples May 18, 2026
ef0caed
Add example: load-a-csv-file-into-memory-using-jsonutility-and-transf…
agent-aspose-cells-examples May 18, 2026
587aa63
Add example: export-a-specific-cell-range-from-a-worksheet-to-json-us…
agent-aspose-cells-examples May 18, 2026
87129fa
Add example: include-column-names-as-keys-in-json-output-by-enabling-…
agent-aspose-cells-examples May 18, 2026
903d0d4
Add example: set-json-output-encoding-to-utf-8-within-jsonsaveoptions…
agent-aspose-cells-examples May 18, 2026
9f5af0e
Add example: batch-process-a-folder-of-xls-files-converting-each-work…
agent-aspose-cells-examples May 18, 2026
6429964
Add example: validate-json-structure-against-a-predefined-schema-afte…
agent-aspose-cells-examples May 18, 2026
208edde
Add example: merge-multiple-json-files-into-a-single-workbook-creatin…
agent-aspose-cells-examples May 18, 2026
3ed141c
Add example: preserve-cell-formulas-during-json-conversion-by-configu…
agent-aspose-cells-examples May 18, 2026
0b37f3e
Add example: generate-prettyprinted-json-with-indentation-by-setting-…
agent-aspose-cells-examples May 18, 2026
8fc2108
Add example: load-a-json-array-representing-multiple-tables-and-map-e…
agent-aspose-cells-examples May 18, 2026
26abff4
Add example: encrypt-the-generated-json-file-using-a-passwordprotecte…
agent-aspose-cells-examples May 18, 2026
bfc1891
Add example: implement-error-handling-to-catch-jsonutilityload-except…
agent-aspose-cells-examples May 18, 2026
a850537
Add example: create-a-console-application-that-prints-json-representa…
agent-aspose-cells-examples May 18, 2026
bd827b7
Add example: configure-jsonsaveoptions-to-exclude-hidden-rows-and-col…
agent-aspose-cells-examples May 18, 2026
139c053
Add example: transform-numeric-values-to-strings-in-json-output-by-ap…
agent-aspose-cells-examples May 18, 2026
6557827
Add example: read-a-json-file-encoded-in-utf16-and-convert-it-to-csv-…
agent-aspose-cells-examples May 18, 2026
589fa33
Add example: generate-json-for-a-pivot-table-by-exporting-its-underly…
agent-aspose-cells-examples May 18, 2026
a22a342
Add example: apply-a-custom-culture-setting-to-format-dates-in-json-a…
agent-aspose-cells-examples May 18, 2026
f9571d3
Add example: create-a-batch-job-that-converts-all-json-files-in-a-dir…
agent-aspose-cells-examples May 18, 2026
370c9fa
Add example: load-an-xls-workbook-remove-empty-columns-then-export-th…
agent-aspose-cells-examples May 18, 2026
e4f9829
Add example: set-jsonlayoutoptionsquoteallfields-to-true-to-ensure-ev…
agent-aspose-cells-examples May 18, 2026
b82b559
Add example: convert-a-json-file-containing-nested-objects-into-a-fla…
agent-aspose-cells-examples May 18, 2026
1f4b9ba
Add example: validate-that-exported-json-includes-expected-number-of-…
agent-aspose-cells-examples May 18, 2026
01768a2
Add example: use-jsonutilityload-with-a-stream-to-read-json-data-from…
agent-aspose-cells-examples May 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,160 @@
"file": "verify-that-the-merged-workbook-contains-the-expected-number-of-worksheets-after-combination.cs",
"title": "Verify that the merged workbook contains the expected number of worksheets after combination."
},
{
"category": "working-with-json",
"file": "apply-a-custom-culture-setting-to-format-dates-in-json-according-to-iso-8601-standard.cs",
"title": "Apply a custom culture setting to format dates in JSON according to ISO 8601 standard."
},
{
"category": "working-with-json",
"file": "batch-process-a-folder-of-xls-files-converting-each-workbook-to-separate-json-files.cs",
"title": "Batch process a folder of XLS files, converting each workbook to separate JSON files."
},
{
"category": "working-with-json",
"file": "configure-jsonsaveoptions-to-exclude-hidden-rows-and-columns-from-the-exported-json-data.cs",
"title": "Configure JsonSaveOptions to exclude hidden rows and columns from the exported JSON data."
},
{
"category": "working-with-json",
"file": "convert-a-json-file-containing-nested-objects-into-a-flattened-json-structure-before-saving.cs",
"title": "Convert a JSON file containing nested objects into a flattened JSON structure before saving."
},
{
"category": "working-with-json",
"file": "convert-a-json-file-containing-tabular-data-to-csv-using-jsonutility-with-a-custom-delimiter.cs",
"title": "Convert a JSON file containing tabular data to CSV using JsonUtility with a custom delimiter."
},
{
"category": "working-with-json",
"file": "create-a-batch-job-that-converts-all-json-files-in-a-directory-to-matching-csv-files.cs",
"title": "Create a batch job that converts all JSON files in a directory to matching CSV files."
},
{
"category": "working-with-json",
"file": "create-a-console-application-that-prints-json-representation-of-the-first-worksheet-to-standard-output.cs",
"title": "Create a console application that prints JSON representation of the first worksheet to standard output."
},
{
"category": "working-with-json",
"file": "define-a-semicolon-as-csv-delimiter-in-jsonlayoutoptions-before-converting-json-to-csv.cs",
"title": "Define a semicolon as CSV delimiter in JsonLayoutOptions before converting JSON to CSV."
},
{
"category": "working-with-json",
"file": "encrypt-the-generated-json-file-using-a-passwordprotected-stream-before-writing-to-disk.cs",
"title": "Encrypt the generated JSON file using a password\u2011protected stream before writing to disk."
},
{
"category": "working-with-json",
"file": "exclude-empty-rows-from-json-output-by-setting-jsonsaveoptionsincludeemptyrows-to-false.cs",
"title": "Exclude empty rows from JSON output by setting JsonSaveOptions.IncludeEmptyRows to false."
},
{
"category": "working-with-json",
"file": "export-a-specific-cell-range-from-a-worksheet-to-json-using-exportrangetojsonoptions.cs",
"title": "Export a specific cell range from a worksheet to JSON using ExportRangeToJsonOptions."
},
{
"category": "working-with-json",
"file": "export-the-active-worksheet-of-the-loaded-workbook-to-json-using-default-saveformat-settings.cs",
"title": "Export the active worksheet of the loaded workbook to JSON using default SaveFormat settings."
},
{
"category": "working-with-json",
"file": "export-the-entire-workbook-to-json-with-column-headers-included-via-jsonsaveoptions.cs",
"title": "Export the entire workbook to JSON with column headers included via JsonSaveOptions."
},
{
"category": "working-with-json",
"file": "generate-json-for-a-pivot-table-by-exporting-its-underlying-data-source-range.cs",
"title": "Generate JSON for a pivot table by exporting its underlying data source range."
},
{
"category": "working-with-json",
"file": "generate-prettyprinted-json-with-indentation-by-setting-jsonsaveoptionsprettyprint-to-true.cs",
"title": "Generate pretty\u2011printed JSON with indentation by setting JsonSaveOptions.PrettyPrint to true."
},
{
"category": "working-with-json",
"file": "implement-error-handling-to-catch-jsonutilityload-exceptions-when-source-json-file-is-malformed.cs",
"title": "Implement error handling to catch JsonUtility.Load exceptions when source JSON file is malformed."
},
{
"category": "working-with-json",
"file": "include-column-names-as-keys-in-json-output-by-enabling-includecolumnnames-option.cs",
"title": "Include column names as keys in JSON output by enabling IncludeColumnNames option."
},
{
"category": "working-with-json",
"file": "load-a-csv-file-into-memory-using-jsonutility-and-transform-it-into-json-format.cs",
"title": "Load a CSV file into memory using JsonUtility and transform it into JSON format."
},
{
"category": "working-with-json",
"file": "load-a-json-array-representing-multiple-tables-and-map-each-element-to-a-separate-worksheet.cs",
"title": "Load a JSON array representing multiple tables and map each element to a separate worksheet."
},
{
"category": "working-with-json",
"file": "load-an-xls-workbook-remove-empty-columns-then-export-the-cleaned-data-to-json.cs",
"title": "Load an XLS workbook, remove empty columns, then export the cleaned data to JSON."
},
{
"category": "working-with-json",
"file": "load-an-xlsx-workbook-from-a-file-path-and-verify-successful-initialization.cs",
"title": "Load an XLSX workbook from a file path and verify successful initialization."
},
{
"category": "working-with-json",
"file": "merge-multiple-json-files-into-a-single-workbook-creating-separate-worksheets-for-each-file.cs",
"title": "Merge multiple JSON files into a single workbook, creating separate worksheets for each file."
},
{
"category": "working-with-json",
"file": "preserve-cell-formulas-during-json-conversion-by-configuring-jsonsaveoptionspreserveformulas-flag.cs",
"title": "Preserve cell formulas during JSON conversion by configuring JsonSaveOptions.PreserveFormulas flag."
},
{
"category": "working-with-json",
"file": "read-a-json-file-encoded-in-utf16-and-convert-it-to-csv-with-utf8-encoding.cs",
"title": "Read a JSON file encoded in UTF\u201116 and convert it to CSV with UTF\u20118 encoding."
},
{
"category": "working-with-json",
"file": "set-json-output-encoding-to-utf-8-within-jsonsaveoptions-before-saving-workbook-as-json.cs",
"title": "Set JSON output encoding to UTF-8 within JsonSaveOptions before saving workbook as JSON."
},
{
"category": "working-with-json",
"file": "set-jsonlayoutoptionsquoteallfields-to-true-to-ensure-every-csv-field-is-enclosed-in-quotes.cs",
"title": "Set JsonLayoutOptions.QuoteAllFields to true to ensure every CSV field is enclosed in quotes."
},
{
"category": "working-with-json",
"file": "specify-a-custom-date-format-in-jsonsaveoptions-before-exporting-workbook-to-json.cs",
"title": "Specify a custom date format in JsonSaveOptions before exporting workbook to JSON."
},
{
"category": "working-with-json",
"file": "transform-numeric-values-to-strings-in-json-output-by-applying-a-custom-value-formatter.cs",
"title": "Transform numeric values to strings in JSON output by applying a custom value formatter."
},
{
"category": "working-with-json",
"file": "use-jsonutilityload-with-a-stream-to-read-json-data-from-a-network-source.cs",
"title": "Use JsonUtility.Load with a stream to read JSON data from a network source."
},
{
"category": "working-with-json",
"file": "validate-json-structure-against-a-predefined-schema-after-loading-with-jsonutility-successfully.cs",
"title": "Validate JSON structure against a predefined schema after loading with JsonUtility successfully."
},
{
"category": "working-with-json",
"file": "validate-that-exported-json-includes-expected-number-of-rows-by-comparing-with-original-worksheet-row-count.cs",
"title": "Validate that exported JSON includes expected number of rows by comparing with original worksheet row count."
}
]
}
87 changes: 87 additions & 0 deletions working-with-json/agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Working With JSON Examples

This folder contains **Aspose.Cells for .NET** code examples related to:

Working With JSON


## Purpose

These examples demonstrate common **Aspose.Cells APIs** used when working with:

- Workbooks
- Worksheets
- Cells
- Formulas
- Charts
- Data operations


## Example Files

Each `.cs` file demonstrates a specific task related to **Working With JSON**.

Example:

create-a-workbook.cs


## Required Namespaces

Most examples will require:

using Aspose.Cells;


## Common Pattern

Typical Aspose.Cells workflow:

Workbook workbook = new Workbook();

Worksheet sheet = workbook.Worksheets[0];

Cells cells = sheet.Cells;


## Output

Examples may generate:

- XLSX files
- PDF files
- CSV files
- Images

Output files are written to the working directory.
- load-an-xlsx-workbook-from-a-file-path-and-verify-successful-initialization.cs
- export-the-active-worksheet-of-the-loaded-workbook-to-json-using-default-saveformat-settings.cs
- export-the-entire-workbook-to-json-with-column-headers-included-via-jsonsaveoptions.cs
- specify-a-custom-date-format-in-jsonsaveoptions-before-exporting-workbook-to-json.cs
- exclude-empty-rows-from-json-output-by-setting-jsonsaveoptionsincludeemptyrows-to-false.cs
- convert-a-json-file-containing-tabular-data-to-csv-using-jsonutility-with-a-custom-delimiter.cs
- define-a-semicolon-as-csv-delimiter-in-jsonlayoutoptions-before-converting-json-to-csv.cs
- load-a-csv-file-into-memory-using-jsonutility-and-transform-it-into-json-format.cs
- export-a-specific-cell-range-from-a-worksheet-to-json-using-exportrangetojsonoptions.cs
- include-column-names-as-keys-in-json-output-by-enabling-includecolumnnames-option.cs
- set-json-output-encoding-to-utf-8-within-jsonsaveoptions-before-saving-workbook-as-json.cs
- batch-process-a-folder-of-xls-files-converting-each-workbook-to-separate-json-files.cs
- validate-json-structure-against-a-predefined-schema-after-loading-with-jsonutility-successfully.cs
- merge-multiple-json-files-into-a-single-workbook-creating-separate-worksheets-for-each-file.cs
- preserve-cell-formulas-during-json-conversion-by-configuring-jsonsaveoptionspreserveformulas-flag.cs
- generate-prettyprinted-json-with-indentation-by-setting-jsonsaveoptionsprettyprint-to-true.cs
- load-a-json-array-representing-multiple-tables-and-map-each-element-to-a-separate-worksheet.cs
- encrypt-the-generated-json-file-using-a-passwordprotected-stream-before-writing-to-disk.cs
- implement-error-handling-to-catch-jsonutilityload-exceptions-when-source-json-file-is-malformed.cs
- create-a-console-application-that-prints-json-representation-of-the-first-worksheet-to-standard-output.cs
- configure-jsonsaveoptions-to-exclude-hidden-rows-and-columns-from-the-exported-json-data.cs
- transform-numeric-values-to-strings-in-json-output-by-applying-a-custom-value-formatter.cs
- read-a-json-file-encoded-in-utf16-and-convert-it-to-csv-with-utf8-encoding.cs
- generate-json-for-a-pivot-table-by-exporting-its-underlying-data-source-range.cs
- apply-a-custom-culture-setting-to-format-dates-in-json-according-to-iso-8601-standard.cs
- create-a-batch-job-that-converts-all-json-files-in-a-directory-to-matching-csv-files.cs
- load-an-xls-workbook-remove-empty-columns-then-export-the-cleaned-data-to-json.cs
- set-jsonlayoutoptionsquoteallfields-to-true-to-ensure-every-csv-field-is-enclosed-in-quotes.cs
- convert-a-json-file-containing-nested-objects-into-a-flattened-json-structure-before-saving.cs
- validate-that-exported-json-includes-expected-number-of-rows-by-comparing-with-original-worksheet-row-count.cs
- use-jsonutilityload-with-a-stream-to-read-json-data-from-a-network-source.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Globalization;
using Aspose.Cells;
using Aspose.Cells.Utility;

class Program
{
static void Main()
{
// Sample JSON containing date strings (any format, they will be parsed and reformatted)
string jsonData = @"[
{ ""Id"": 1, ""Date"": ""15/05/2023 13:45:30"" },
{ ""Id"": 2, ""Date"": ""2023-06-20T09:15:00"" }
]";

// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Ensure culture‑independent formatting (ISO 8601) by using InvariantCulture
workbook.Settings.CultureInfo = CultureInfo.InvariantCulture;

// Configure JSON import options:
// - Convert strings that look like dates to actual DateTime values
// - Use ISO 8601 format when writing dates back to JSON
JsonLayoutOptions layoutOptions = new JsonLayoutOptions
{
ArrayAsTable = true,
ConvertNumericOrDate = true,
DateFormat = "yyyy-MM-ddTHH:mm:ss" // ISO 8601 pattern
};

// Import the JSON data into the worksheet using the layout options
JsonUtility.ImportData(jsonData, worksheet.Cells, 0, 0, layoutOptions);

// Prepare JSON save options (optional indentation for readability)
JsonSaveOptions saveOptions = new JsonSaveOptions
{
Indent = " ", // two spaces
ExportArea = new CellArea
{
StartRow = 0,
EndRow = worksheet.Cells.MaxDataRow,
StartColumn = 0,
EndColumn = worksheet.Cells.MaxDataColumn
},
HasHeaderRow = true
};

// Save the workbook as JSON; dates will appear in ISO 8601 format
workbook.Save("output.json", saveOptions);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.IO;
using Aspose.Cells.Utility;

namespace AsposeCellsBatchJsonExport
{
class Program
{
static void Main()
{
// Folder containing the source Excel files (XLS format)
string sourceFolder = @"C:\InputExcelFiles";

// Ensure the folder exists
if (!Directory.Exists(sourceFolder))
{
Console.WriteLine($"Source folder does not exist: {sourceFolder}");
return;
}

// Get all .xls files in the folder (non‑recursive)
string[] excelFiles = Directory.GetFiles(sourceFolder, "*.xls");

if (excelFiles.Length == 0)
{
Console.WriteLine("No XLS files found in the specified folder.");
return;
}

foreach (string excelPath in excelFiles)
{
try
{
// Build the output JSON file path – same name, .json extension, placed in the same folder
string jsonPath = Path.ChangeExtension(excelPath, ".json");

// Convert the Excel workbook to JSON using Aspose.Cells.Utility.ConversionUtility
// This uses the rule: ConversionUtility.Convert(string source, string saveAs)
ConversionUtility.Convert(excelPath, jsonPath);

Console.WriteLine($"Converted '{Path.GetFileName(excelPath)}' to '{Path.GetFileName(jsonPath)}'.");
}
catch (Exception ex)
{
Console.WriteLine($"Error converting file '{excelPath}': {ex.Message}");
}
}

Console.WriteLine("Batch conversion completed.");
}
}
}
Loading