Convert JSON to Excel Linux

JSON files are immensely used to store and transmit structured data. However, in certain cases, you may need to import data from JSON files to Excel spreadsheets. To achieve this programmatically, this article covers how to convert JSON files to Excel XLSX or XLS format on the Linux platform.

API to Import Data from JSON to Excel on Linux

Aspose.Cells for Java is a robust, feature‑rich API that enables creation, manipulation, and conversion of spreadsheet documents with high fidelity. It supports Linux environments and provides dedicated classes for handling JSON data. You can obtain the library as a downloadable JAR file or add it to your Maven project with the repository and dependency definitions below.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-cells</artifactId>
    <version>21.9</version>
</dependency>

Import JSON Data to Excel on Linux

Follow these detailed steps to transform a JSON file into an Excel worksheet on Linux:

  1. Read the JSON file – Load the entire JSON content into a String variable.
  2. Create a workbook – Instantiate the Workbook class, which represents an Excel file.
  3. Select the target worksheet – Retrieve the first Worksheet object from the workbook where the data will be placed.
  4. Configure layout options – Create a JsonLayoutOptions object to control how arrays and objects are rendered.
  5. Set array handling – Use JsonLayoutOptions.setArrayAsTable(true) to import JSON arrays as Excel tables.
  6. Import the JSON data – Call JsonUtility.importData(jsonString, worksheet.getCells(), 0, 0, layoutOptions) to populate the worksheet.
  7. Save the workbook – Persist the workbook to disk in either XLSX or XLS format with Workbook.save(filePath, SaveFormat.XLSX) (or SaveFormat.XLS).

The code snippet below demonstrates the complete process in Java.

Get a Free License

You can use Aspose.Cells for Java without evaluation limitations by obtaining a temporary license.

Conclusion

This guide showed how to import JSON data into Excel XLSX or XLS files on a Linux system using Aspose.Cells for Java. For deeper integration, explore the full documentation or ask questions in the forum.

See Also