[]
        
(Showing Draft Content)

Import and Export SpreadJS Files

DsExcel Java supports SSJSON and SJS I/O of SpreadJS files. You can import, modify, and export files created with the SpreadJS designer.

SJS and SSJSON File Format

SpreadJS v16 introduced a new file format, .sjs, to work with large and complex files faster and generate smaller files (in size) when saved. The new .sjs format is a zipped file that contains multiple smaller JSON files and is structured similarly to the Excel XML structure. DsExcel Java allows you to import and export the new .sjs file format just like the XLSX, CSV, and other file formats.

Below, you will find detailed information about SJS Options and SSJSON Options to help you work with these formats and customize their behavior to suit your needs.

SJS Options

You can import a .sjs file using the open method of Workbook class. Once loaded in DsExcel, it can be exported to Excel (XLSX) or back to .sjs file using the save method of Workbook class. While loading or saving a .sjs file, you can use the new option "Sjs" in OpenFileFormat and SaveFileFormat enums.

Refer to the following example code to import and export a .sjs file from the file name:

// Initialize Workbook.
Workbook workbook = new Workbook();

// Open .sjs file.
workbook.open("ProjectPlan.sjs", OpenFileFormat.Sjs);

// Save .sjs file.
workbook.save("SaveProjectPlan.sjs", SaveFileFormat.Sjs);

Refer to the following example code to import and export a .sjs file from a file stream:

// Create a new workbook.
var streamworkbook = new Workbook();
// Create a new file stream to open a file.
InputStream openFile;
try {
    openFile = new FileInputStream("ProjectPlan.sjs");
    // Open xltx file.
    streamworkbook.open(openFile, OpenFileFormat.Sjs);
} catch (FileNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
  
// Create a new file stream to save a file.
OutputStream out;
try {
    out = new FileOutputStream("SaveProjectPlan.sjs");
    // Save workbook as xltx file.
    streamworkbook.save(out, SaveFileFormat.Sjs);
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

In addition, DsExcel provides SjsOpenOptions and SjsSaveOptions classes to customize the import and export of a .sjs file. These options are especially useful in dealing with large files, such as those containing many formulas, styles, or unused names. These options are listed below:

Class

Option

Description

Import Options

SjsOpenOptions

setIncludeStyles

Indicates whether the style can be included when loading .sjs files. By default, it is true.

setIncludeFormulas

Indicates whether the formula can be included when loading .sjs files. By default, it is true.

Export Options

SjsSaveOptions

setIncludeStyles

Indicates whether the style can be included when saving files. By default, the value is true.

setIncludeFormulas

Indicates whether the formula can be included when saving the file. By default, the value is true.

setIncludeUnusedNames

Indicates whether the unused custom name can be included when saving the file. By default, the value is true.

setIncludeEmptyRegionCells

Indicates whether any empty cells outside the used data range can be included while saving the file. By default, the value is true.

setIgnoreRangeOutOfRowCoulumnCount

Indicates whether to ignore data out of RowCount and ColumnCount while saving the file. By default, the value is false.

setIncludeAutoMergedCells

Indicates whether to include the automatically merged cells. By default, the value is false.

setIncludeBindingSource

Indicates whether to include the binding source when saving the file. By default, the value is true.

Refer to the following example code to import and export a .sjs file using SjsOpenOptions and SjsSaveOptions:

// Initialize Workbook.
Workbook workbook = new Workbook();

// Open a .sjs file with formulas.
SjsOpenOptions openOptions = new SjsOpenOptions();
openOptions.setIncludeFormulas(false);
openOptions.setIncludeStyles(false);
workbook.open("ProjectPlan.sjs", openOptions);

// Save the .sjs file with styles.
SjsSaveOptions saveOptions = new SjsSaveOptions();
saveOptions.setIncludeStyles(false);
saveOptions.setIncludeFormulas(true);
saveOptions.setIncludeUnusedNames(false);
saveOptions.setIncludeEmptyRegionCells(false);
workbook.save("SaveProjectPlan.sjs", saveOptions);

DsExcel provides toSjsJson method that integrates all JSON files from the .sjs file into a single string or stream. Furthermore, DsExcel also provides fromSjsJson, which loads a string or stream of all JSON files generated from .sjs file. These methods also support SjsOpenOptions and SjsSaveOptions.

Methods

Description

toSjsJson()

Generates a JSON string from a workbook. It integrates all JSON files from the .sjs file into a single string.

toSjsJson(SjsSaveOptions options)

Generates a JSON string from a workbook using save options. It integrates all JSON files from the .sjs file into a single string.

toSjsJson(Stream stream)

Integrates all JSON files from the .sjs file into a single string, then puts the string into the stream.

toSjsJson(Stream stream, SjsSaveOptions options)

Integrates all JSON files from the .sjs file into a single string using save options, then puts the string into the stream.

fromSjsJson(string json)

Generates a workbook from a JSON string containing the contents of .sjs file format.

fromSjsJson(string json,

SjsOpenOptions options)

Generates a workbook from a JSON string using open options containing the contents of .sjs file format.

fromSjsJson(Stream stream)

Generates a workbook from a JSON stream containing the contents of .sjs file format.

fromSjsJson(Stream stream, SjsOpenOptions options)

Generates a workbook from a JSON stream using open options containing the contents of .sjs file format.

Refer to the following example code to export and import a single JSON string generated from .sjs file:

// Initialize Workbook.
Workbook workbook = new Workbook();

// Open workbook.
workbook.open("12-month cash flow statement1.sjs");

// Generate a JSON string for .sjs file and save it to a stream.
OutputStream outputStream;
try {
    outputStream = new FileOutputStream("CashFlow.json");
    workbook.toSjsJson(outputStream);
    outputStream.close();
} catch (FileNotFoundException e) {
    e.printStackTrace();        
}

// Import a JSON string from the stream and save it as an Excel file.
InputStream inputStream;
try {
    inputStream = new FileInputStream("CashFlow.json");
    workbook.fromSjsJson(inputStream);
} catch (FileNotFoundException e) {
    e.printStackTrace();        
}

// Save workbook.
workbook.save("CashFlow.xlsx");

SSJSON Options

In SpreadJS, while importing or exporting custom data from or to a JSON object, you can set several serialization or deserialization options. DsExcel API supports some of these options for workbook and worksheet JSON I/O. The below table explains the supported options in SpreadJS and DsExcel.


SpreadJS (toJSON and fromJSON)

DsExcel (toJSON and fromJSON)

Serialization

ignoreStyle

ignoreFormula

rowHeadersAsFrozenColumns

columnHeadersAsFrozenRows

setIgnoreStyle

setIgnoreFormula

setIgnoreSheets

setIgnoreColumnRowInfoOutOfUsedRange

setIgnoreColumnRowInfoOutOfUsedRange

setIgnoreRangeOutOfRowColumnCount

setIgnoreRangeOutOfRowColumnCount

setExportSharedFormula

setIncludeAutoMergedCells

setIncludeBindingSource

Deserialization

ignoreStyle

ignoreFormula

frozenColumnsAsRowHeaders

frozenRowsAsColumnHeaders

doNotRecalculateAfterLoad

setIgnoreStyle

setIgnoreFormula

setDoNotRecalculateAfterLoad

DsExcel provides SerializationOptions and DeserializationOptions classes in API with above-mentioned supported methods.

The following example code serializes a workbook to JSON with options in DsExcel.

// Ignore style and formula when deserialize workbook from json.
DeserializationOptions deserializationOptions = new DeserializationOptions();
deserializationOptions.setIgnoreStyle(true);
deserializationOptions.setIgnoreFormula(true);
workbook.fromJson(json, deserializationOptions);

// Save to an excel file
workbook.save("FromJsonWithOptions.xlsx");

The following example code deserializes a workbook from JSON with options in DsExcel.

// Ignore style and formula when serialize workbook to json.
SerializationOptions serializationOptions = new SerializationOptions();
serializationOptions.setIgnoreStyle(true);
serializationOptions.setIgnoreFormula(true);

String jsonWithOption = workbook.toJson(serializationOptions);

workbook.fromJson(jsonWithOption);

// Save to an excel file
workbook.save("ToJsonWithOptions.xlsx");

You can control the size of exported JSON file by choosing whether you want to keep the style and size of rows and columns which are out of the used range. The setIgnoreColumnRowInfoOutOfUsedRange method is provided in SerializationOptions class which:

  • When set to true (default value), does not export the style and size of rows and columns which are out of the used range and hence, the file size is smaller.

  • When set to false, exports the style and size of rows and columns which are out of the used range and hence, the file size is larger.

The following example code shows how the size of JSON file is impacted by setting the above mentioned method.

Workbook book = new Workbook();
 
IWorksheet worksheet = book.getWorksheets().get(0);
//Add custom name style.
IStyle style = book.getStyles().add("testStyle1");
     
style.getFont().setThemeColor(ThemeColor.Accent1);
style.getFont().setTintAndShade(0.8);
style.getFont().setItalic(true);
style.getFont().setBold(true);
style.getFont().setName("LiSu");
style.getFont().setSize(28);
style.getFont().setStrikethrough(true);
style.getFont().setSubscript(true);
style.getFont().setSuperscript(false);
style.getFont().setUnderline(UnderlineType.Double);
     
Object data = new Object[][]{
    {"test", "test", "test", "test" },
    {"test", "test", "test", "test" },
    {"test", "test", "test", "test" },
    {"test", "test", "test", "test" },
    {"test", "test", "test", "test" },
};
     
worksheet.getRange("B2:E6").setValue(data);
worksheet.getRange("A:XFD").setStyle(style);
worksheet.getRange("A:XFD").setColumnWidthInPixel(20);
        
//Export sizes/styles of only used range to json
SerializationOptions options = new SerializationOptions();
options.setIgnoreColumnRowInfoOutOfUsedRange(true);
        
try {
    book.toJson(new FileOutputStream("TestJson_true.json"), options);    // Size of output file is 9KB
} catch (FileNotFoundException e1) {
    e1.printStackTrace();
}
        
//Export all sizes/styles to json
SerializationOptions options2 = new SerializationOptions();
options2.setIgnoreColumnRowInfoOutOfUsedRange(false);
        
try {
    book.toJson(new FileOutputStream("TestJson_false.json"), options2);    // Size of output file is 809KB
} catch (FileNotFoundException e1) {
    e1.printStackTrace();
}
        
//Default behavior (same as true option)
try {
    book.toJson(new FileOutputStream("TestJson_default.json"));    // Size of output file is 9KB
} catch (FileNotFoundException e) {
    e.printStackTrace();
}

You can also control whether to export formulas as shared formulas when exporting to a JSON file using the setExportSharedFormula method in SerializationOptions class. This enables you to export the formulas as shared formulas when it is set to true (the default value). However, if the value is set to false, the formulas will be exported as individual formulas.

In DsExcel v6.0.1 and higher versions, the formula is exported as a shared formula to a JSON file (or SSJSON file). Because the shared formula is not compatible with DsExcel versions less than or equal to v5 and SpreadJS versions less than or equal to v15, you can use this option for backward compatibility and skip shared formulas in the exported JSON file.

The following example code exports formulas as shared formulas:

// Create a new workbook.
 var workbook = new Workbook();

 // Set options for iterative calculation.
 workbook.getOptions().getFormulas().setEnableIterativeCalculation(true);
 workbook.getOptions().getFormulas().setMaximumIterations(20);
 var worksheet = workbook.getWorksheets().get(0);

 // Set values and formulas.
 worksheet.getRange("B2").setValue("Initial Cash");
 worksheet.getRange("C2").setValue(10000);
 worksheet.getRange("B3").setValue("Interest");
 worksheet.getRange("C3").setValue(0.0125);

 worksheet.getRange("B5").setValue("Month");
 worksheet.getRange("C5").setValue("Total Cash");  

 worksheet.getRange("B6:B17").setValue(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });  

 worksheet.getRange("C6").setFormula("=C2*(1+$C$3)");  
 worksheet.getRange("C7:C17").setFormula("=C6*(1+$C$3)");  

 // Initialize SerializationOptions and set ExportSharedFormula to true.
 SerializationOptions options = new SerializationOptions();
 options.setExportSharedFormula(true);

 // Save the JSON file.
 PrintWriter out1;
try {
    out1 = new PrintWriter("ExportSharedFormulas.json");
    out1.println(workbook.toJson(options));
} catch (FileNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}     

 // Initialize SerializationOptions and set ExportSharedFormula to false.
 SerializationOptions options2 = new SerializationOptions();
 options2.setExportSharedFormula(false);

 // Save the JSON file.
 PrintWriter out2;
try {
    out2 = new PrintWriter("ExportIndividualFormulas.json");
    out2.println(workbook.toJson(options));
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Note: SpreadJS supports multi-level row or column headers but DsExcel does not. However, you can still retain the header information in DsExcel by following the below steps:

  1. Use SpreadJS to export JSON with 'rowHeadersAsFrozenColumns or columnHeadersAsFrozenRows' option as true to convert multi-header to frozen area, and use DsExcel to load the JSON file.

  2. Manipulate the frozen area in DsExcel.

  3. Use DsExcel to export JSON file, and use SpreadJS to load JSON file with 'frozenColumnsAsRowHeaders or frozenRowsAsColumnHeaders ' option as true to convert frozen area to header.

DsExcel allows you to convert skeleton of the workbook into a JSON stream. That is, you can export a workbook with just the worksheet without any data in them. This can be implemented by setting the SerializationOptions.setIgnoreSheets method to true and then pass it as a parameter while calling the IWorkbook.toJson method.

You can also export the worksheet only to a separate JSON stream by using the IWorksheet.toJson(Stream stream) method. Similarly, IWorkSheet.fromJson(Stream stream) lets you import the worksheets from JSON stream when required.

This feature is especially useful in optimizing the performance while loading large workbooks with many worksheets containing complex formula. Using the above-mentioned methods, you can load an empty workbook first with worksheet names and load the worksheet data when user selects a worksheet tab.

The example below demonstrates how you can export the workbook and worksheet to separate JSON streams and load them in a new workbook instance when required.

// Create a new workbook
Workbook workbook = new Workbook();

// The old workbook.
IWorkbook oldWorkbook = new com.grapecity.documents.excel.Workbook();

InputStream fileStream = getResourceStream("xlsx\\12-month cash flow statement1.xlsx");
oldWorkbook.open(fileStream);

FileOutputStream workbookOutputJson = null;
FileInputStream workbookInputJson = null;
FileOutputStream worksheetOutputJson = null;
FileInputStream worksheetInputJson = null;

try {
    SerializationOptions serializationOptions = new SerializationOptions();
    serializationOptions.setIgnoreSheets(true);
    
    // Export the skeleton of the workbook without worksheets to json stream. 
    workbookOutputJson = new FileOutputStream("workbookJava.json");
    oldWorkbook.toJson(workbookOutputJson, serializationOptions);
    
    // Import the workbook stream.
    workbookInputJson = new FileInputStream("workbookJava.json");
    workbook.fromJson(workbookInputJson);

    // Export the worksheet to json stream. 
    worksheetOutputJson = new FileOutputStream("worksheetJava.json");
    oldWorkbook.getActiveSheet().toJson(worksheetOutputJson);

    // Import the worksheet stream.
    worksheetInputJson = new FileInputStream("worksheetJava.json");
    workbook.getActiveSheet().fromJson(worksheetInputJson);
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} finally {
    // Close streams.
    try {
        if (workbookOutputJson != null) {
            workbookOutputJson.close();
        }
        
        if (workbookInputJson != null) {
            workbookInputJson.close();
        }
        
        if (worksheetOutputJson != null) {
            worksheetOutputJson.close();
        }
        
        if (worksheetInputJson != null) {
            worksheetInputJson.close();
        }
    } catch (Exception e2) {
        // TODO: handle exception
    }
}
    
// Save to an excel file
workbook.save("WorkbookToJsonWithoutSheets.xlsx");

Control Bound Data Export

DsExcel enables you to control whether to export the bound data source by using the setIncludeBindingSource method of SjsSaveOptions—when exporting to a .sjs file, use the property in SjsSaveOptions; when exporting to a .ssjson file, use the property in SerializationOptions.

Refer to the following example code to exclude the binding source when exporting to .sjs file:

// Create a new workbook.
var workbook = new Workbook();

// Define a JSON data source.
String dataSource = "{ \"ds\":" +
        "[\n" +
        "   {\"Area\": \"North America\",\"City\": \"Chicago\",\"Category\": \"Consumer Electronics\",\"Name\": \"Bose 785593-0050\",\"Revenue\": 92800},\n" +
        "   {\"Area\": \"North America\",\"City\": \"New York\",\"Category\": \"Consumer Electronics\",\"Name\": \"Bose 785593-0050\",\"Revenue\": 92800},\n" +
        "   {\"Area\": \"South America\",\"City\": \"Santiago\",\"Category\": \"Consumer Electronics\",\"Name\": \"Bose 785593-0050\",\"Revenue\": 19550},\n" +
        "   {\"Area\": \"Europe\",\"City\": \"Berlin\",\"Category\": \"Consumer Electronics\",\"Name\": \"Sony WH-1000XM4\",\"Revenue\": 30000},\n" +
        "   {\"Area\": \"Asia\",\"City\": \"Tokyo\",\"Category\": \"Consumer Electronics\",\"Name\": \"Sony WH-1000XM4\",\"Revenue\": 45000},\n" +
        "   {\"Area\": \"North America\",\"City\": \"Los Angeles\",\"Category\": \"Consumer Electronics\",\"Name\": \"Apple AirPods\",\"Revenue\": 60000},\n" +
        "   {\"Area\": \"Europe\",\"City\": \"Paris\",\"Category\": \"Consumer Electronics\",\"Name\": \"Apple AirPods\",\"Revenue\": 55000},\n" +
        "   {\"Area\": \"Asia\",\"City\": \"Seoul\",\"Category\": \"Consumer Electronics\",\"Name\": \"Samsung Galaxy Buds\",\"Revenue\": 40000},\n" +
        "   {\"Area\": \"South America\",\"City\": \"Buenos Aires\",\"Category\": \"Consumer Electronics\",\"Name\": \"Samsung Galaxy Buds\",\"Revenue\": 35000},\n" +
        "   {\"Area\": \"North America\",\"City\": \"Toronto\",\"Category\": \"Consumer Electronics\",\"Name\": \"Bose 785593-0050\",\"Revenue\": 50000}\n" +
        " ]" +
        "}";

// Add data source to worksheet.
IWorksheet dataSourceSheet = workbook.getWorksheets().add();
dataSourceSheet.setName("DataSource");
ITable table = dataSourceSheet.getTables().add(dataSourceSheet.getRange("A1:E4"), true);

// Set binding path.
table.setBindingPath("ds");
table.getColumns().get(0).setDataField("Area");
table.getColumns().get(1).setDataField("City");
table.getColumns().get(2).setDataField("Category");
table.getColumns().get(3).setDataField("Name");
table.getColumns().get(4).setDataField("Revenue");

// Set data source.
dataSourceSheet.setDataSource(new JsonDataSource(dataSource));

// Create pivot table sheet.
IWorksheet pivotSheet = workbook.getWorksheets().get(0);
pivotSheet.setName("PivotSheet");

// Create pivot table.
IPivotCache pivotcache = workbook.getPivotCaches().create(table);
IPivotTable pivottable = pivotSheet.getPivotTables().add(pivotcache, pivotSheet.getRange("A1"), "pivottable1");

// Configure pivot table fields.
IPivotField fieldArea = pivottable.getPivotFields().get("Area");
fieldArea.setOrientation(PivotFieldOrientation.RowField);
IPivotField fieldCity = pivottable.getPivotFields().get("City");
fieldCity.setOrientation(PivotFieldOrientation.RowField);
IPivotField fieldName = pivottable.getPivotFields().get("Name");
fieldName.setOrientation(PivotFieldOrientation.ColumnField);
IPivotField fieldRevenue = pivottable.getPivotFields().get("Revenue");
fieldRevenue.setOrientation(PivotFieldOrientation.DataField);
pivotSheet.getUsedRange().autoFit();
pivottable.setColumnGrand(false);
pivottable.setRowGrand(false);
pivottable.refresh();

SjsSaveOptions saveOptions = new SjsSaveOptions();

// If exporting in SSJSON format, uncomment this line.
//SerializationOptions saveOptions = new SerializationOptions();

// Set IncludeBindingSource property to false to exclude the binding source from being exported.
saveOptions.setIncludeBindingSource(false);

// Save the workbook.
workbook.save("IncludeBindingSourceOption.sjs", saveOptions);

// If you want to export SSJSON, uncomment the following code.
/*
try 
{
    // Save the workbook.
    workbook.toJson(new FileOutputStream("IncludeBindingSourceOption.ssjson"), saveOptions);
} 
catch (FileNotFoundException e1) {
    e1.printStackTrace();
}
*/

Note: setIncludeBindingSource method will not revert the table to its original size after the DataBinding has changed its size. This method only controls whether the data is exported.

Row and Column Count

DsExcel allows you to set the count of rows and columns in a worksheet while performing .sjs or JSON I/O. setRowCount and setColumnCount methods of the IWorksheet interface enable you to achieve the same. setRowCount and setColumnCount methods also increase or decrease the row and column count when you insert or delete the rows or columns.

You can also use the setIgnoreRangeOutOfRowColumnCount method of SjsSaveOptions class and setIgnoreRangeOutOfRowColumnCount method of SerializationOptions class to choose whether to ignore the data outside the range of the specified row and column count. The default value of this method is false, which exports the data outside the range of the specified row and column count to .sjs or JSON.

Refer to the following example code to set the row and column count in a worksheet and export it to a .sjs file or a .ssjson file:

// Create a new workbook
Workbook workbook = new Workbook();

// --------------- For .sjs Export ---------------

// Open .sjs file.
workbook.open("LoanDetails.sjs", OpenFileFormat.Sjs);

// Access the first worksheet.
IWorksheet worksheet = workbook.getWorksheets().get(0);

// Set row and column count to 4.
worksheet.setRowCount(4);
worksheet.setColumnCount(4);

// Configure export to ignore data outside the row/column count.
SjsSaveOptions sjsSaveOptions = new SjsSaveOptions();
sjsSaveOptions.setIgnoreRangeOutOfRowColumnCount(true);

// Save as .sjs file.
workbook.save("IgnoreDataOption.sjs", sjsSaveOptions);

// --------------- For SSJSON Export ---------------
// If you want to export as SSJSON, uncomment the following code.

/*
IWorksheet worksheet2 = workbook.getWorksheets().get(0);

// Example of setting cell data
worksheet2.getRange("A1").setValue(1);
worksheet2.getRange("A11").setValue(2);

// Set row and column count to 10.
worksheet2.setRowCount(10);
worksheet2.setColumnCount(10);

// Configure export to ignore data outside the row/column count.
SerializationOptions ssjsonOptions = new SerializationOptions();
ssjsonOptions.setIgnoreRangeOutOfRowColumnCount(true);

// Save as SSJSON file (JSON).
// Open this JSON file with SpreadJS to see that row/column count is 10.
try {
    workbook.toJson(new FileOutputStream("RowColumnCount.json"), ssjsonOptions);
} catch (FileNotFoundException e) {
    e.printStackTrace();
}
*/

Limitations

  • The row and column count setting is only supported for .sjs and JSON I/O, and cannot be exported to Excel or PDF file.

  • setRowCount and setColumnCount cannot exceed the maximum row limit of 1,048,576 and the column limit of 16,384 in MS Excel.

Retreive Errors while Importing JSON Files

DsExcel provides the option to get JSON errors, if any, while importing the JSON file using fromJson method of IWorkbook interface. The error message is displayed by the getErrorMessage property of JsonError class. Two types of error messages are supported:

  • Formula JSON Error - Implemented using the FormulaJsonError class and can be raised in case of a formula error in JSON file

  • Data Validation JSON Error - Implemented using the DataValidationJsonError class and can be raised in case of a data validation error in JSON file

Refer to the below example code which will display a formula JSON error as the JSON file containing formula error is imported in DsExcel.

// create a new workbook
Workbook workbook = new Workbook();
// Open JSON file contaning JSON errors
InputStream stream = new FileInputStream("ErrorJson.json");

List<JsonError> errors = workbook.fromJson(stream);
for (JsonError item : errors) {
    if (item instanceof FormulaJsonError) {
        FormulaJsonError fError = (FormulaJsonError) item;
        System.out
                .println(fError.getErrorMessage() + " "
                        + workbook.getWorksheets().get(fError.getWorksheetName())
                                .getRange(fError.getRow(), fError.getColumn()).toString()
                        + " " + fError.getFormula());
    }

    if (item instanceof DataValidationJsonError) {
        DataValidationJsonError dError = (DataValidationJsonError) item;
        System.out.println(dError.getErrorMessage() + " "
                + workbook.getWorksheets().get(dError.getWorksheetName()).getRange(dError.getRange().toString())
                + " " + dError.getErrorContent());
    }

Limitation

If the data validation in JSON file has error in its formula, Data Validation JSON error will be generated.