Convert Excel to JSON in C#

JSON is a popular format to exchange data within or between the applications. The lightweight JSON files make it possible for you to store and process small or large sized data easily. On the other hand, Excel worksheets are commonly used to keep and share the data. However, in certain cases, you may need to convert Excel data to JSON format from within .NET applications. To achieve that, this article covers how to convert Excel to JSON programmatically in C#.

Steps to Convert Excel to JSON in C#

To convert the Excel files to JSON format in C#, we will use Aspose.Cells for .NET. The library hides the complex conversion operations and lets you convert Excel files to JSON format within a couple of steps. The following simple steps would be required to convert an Excel file to JSON.

  • Load the Excel file from disk.
  • Save it in JSON format to desired location.

The following section demonstrates how to download or install Aspose.Cells for .NET.

C# Excel to JSON Converter – Free Download

Aspose.Cells for .NET is a high-speed and powerful library to create and process Excel files seamlessly. In addition, it provides a high fidelity converter for back and forth conversion of Excel files. You can download it’s DLL from the downloads section or install it from NuGet.

PM> Install-Package Aspose.Cells

Export Excel File to JSON in C#

In Excel to JSON conversion, Aspose.Cells for .NET converts each row of the worksheet into an object of JSON. The following are the steps to convert an Excel file to JSON in C#.

  • Load the Excel file using Workbook class by specifying its path.
  • Save Excel file into JSON format using Workbook.Save method.

The following code sample shows how to perform Excel to JSON export in C#.

C# Library for Excel to JSON Export - Get a Free License

You can get a free temporary license to use all the features of Aspose.Cells for .NET without any limitations.

Conclusion

In this article, you have learned how to convert Excel files to JSON format programmatically in C#. You can simply install Aspose.Cells for .NET into your applications and perform Excel to JSON export in C# within a couple of steps. Furthermore, you may go through the documentation of Aspose.Cells for .NET to explore other features. In case you would have any queries, please feel free to contact us at the forum.

See Also