Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
There is no need to wonder how to convert a JSON file to an Excel file, because Aspose.Cells for Node.js via C++ provides the best solution. The Aspose.Cells API provides support for converting JSON format to spreadsheets. You can use JsonLoadOptions class to specify additional settings for importing JSON to a Workbook.
The following code example demonstrates importing JSON to an Excel Workbook. Please see the code to convert the source file to the XLSX file generated by the example for reference.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.json");
// create a Workbook object
const wb = new AsposeCells.Workbook(filePath);
// save file to XLSX format
wb.save("sample_out.xlsx");
The following code example, which uses the JsonLoadOptions class to specify additional settings, demonstrates importing JSON to an Excel Workbook. Please see the code to convert the source file to the XLSX file generated by the example for reference.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.json");
// Create an options object for loading the file.
const options = new AsposeCells.JsonLoadOptions();
options.setMultipleWorksheets(true);
// Loads the workbook from JSON file
const book = new AsposeCells.Workbook(filePath, options);
// Save file in XLSX format
book.save("sample_out.xlsx");
The following code example demonstrates importing a JSON string to an Excel Workbook. You can also specify the location of the layout when importing JSON. Please see the code to convert a JSON string to the XLSX file generated by the example for reference.
const AsposeCells = require("aspose.cells.node");
const path = require("path");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const inputJson = JSON.stringify([
{ BEFORE: 'before cell', TEST: 'asd1', AFTER: 'after cell' },
{ BEFORE: 'before cell', TEST: 'asd2', AFTER: 'after cell' },
{ BEFORE: 'before cell', TEST: 'asd3', AFTER: 'after cell' },
{ BEFORE: 'before cell', TEST: 'asd4', AFTER: 'after cell' }
]);
const sheetName = "Sheet1";
const row = 3;
const column = 2;
// create a Workbook object
const book = new AsposeCells.Workbook();
const worksheet = book.getWorksheets().get(sheetName);
// set JsonLayoutOptions to treat arrays as a table
const jsonLayoutOptions = new AsposeCells.JsonLayoutOptions();
jsonLayoutOptions.setArrayAsTable(true);
AsposeCells.JsonUtility.importData(inputJson, worksheet.getCells(), row, column, jsonLayoutOptions);
// save file to XLSX format
book.save("out.xlsx");
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.