[]
        
(Showing Draft Content)

DataValidationJsonError

Class DataValidationJsonError

java.lang.Object
com.grapecity.documents.excel.JsonError
com.grapecity.documents.excel.DataValidationJsonError

public class DataValidationJsonError extends JsonError
Represents a JSON import error related to data validation.

Use this class to inspect details about a data validation entry that could not be processed during JSON import, such as the worksheet that contains the error, the affected range, and the validation content that caused the error. Instances of this class can be reported in the list returned by Workbook.fromJson(String).


 Workbook sourceWorkbook = new Workbook();
 IValidation validation = sourceWorkbook.getWorksheets().get(0).getRange("A1:A3").getValidation();
 validation.add(ValidationType.Custom, ValidationAlertStyle.Stop,
     ValidationOperator.Between, "=A1>0", null);
 String json = sourceWorkbook.toJson().replace("A1>0", "A1>");
 Workbook importedWorkbook = new Workbook();
 List<JsonError> errors = importedWorkbook.fromJson(json);
 DataValidationJsonError error = (DataValidationJsonError) errors.get(0);
 String range = error.getRange();
 
  • Constructor Details

    • DataValidationJsonError

      public DataValidationJsonError(String errorMessage, String worksheetName, String range, String errorContent)
      Creates a data validation JSON error with the specified details.
      Parameters:
      errorMessage - The error message.
      worksheetName - The worksheet name.
      range - The cell range associated with the error.
      errorContent - The validation content that caused the error.
  • Method Details

    • getWorksheetName

      public String getWorksheetName()
      Gets the name of the worksheet where this data validation JSON error occurred.

      This method returns the worksheet name stored in this DataValidationJsonError when the error object was created. The value identifies the worksheet that contains the data validation entry that could not be processed during JSON import.

      
       Workbook sourceWorkbook = new Workbook();
       IValidation validation = sourceWorkbook.getWorksheets().get(0).getRange("A1:A3").getValidation();
       validation.add(ValidationType.Custom, ValidationAlertStyle.Stop,
           ValidationOperator.Between, "=A1>0", null);
       String json = sourceWorkbook.toJson().replace("A1>0", "A1>");
       Workbook importedWorkbook = new Workbook();
       List<JsonError> errors = importedWorkbook.fromJson(json);
       DataValidationJsonError error = (DataValidationJsonError) errors.get(0);
       String worksheetName = error.getWorksheetName();
       
      Returns:
      The worksheet name associated with this error. Returns null if no worksheet name was stored.
    • getRange

      public String getRange()
      Gets the cell range associated with the data validation error.

      This method returns the range string recorded for the data validation error when JSON content is imported and a data validation issue is detected.

      
       Workbook sourceWorkbook = new Workbook();
       IValidation validation = sourceWorkbook.getWorksheets().get(0).getRange("A1:A3").getValidation();
       validation.add(ValidationType.Custom, ValidationAlertStyle.Stop,
           ValidationOperator.Between, "=A1>0", null);
       String json = sourceWorkbook.toJson().replace("A1>0", "A1>");
       Workbook importedWorkbook = new Workbook();
       List<JsonError> errors = importedWorkbook.fromJson(json);
       DataValidationJsonError error = (DataValidationJsonError) errors.get(0);
       String range = error.getRange();
       
      Returns:
      The range string for the data validation error.
    • getErrorContent

      public String getErrorContent()
      Gets the data validation content that caused this JSON error.

      This method returns the validation content captured for a data validation entry that could not be processed during JSON import, such as a formula or other validation definition stored with the error details.

      
       Workbook sourceWorkbook = new Workbook();
       IValidation validation = sourceWorkbook.getWorksheets().get(0).getRange("A1:A3").getValidation();
       validation.add(ValidationType.Custom, ValidationAlertStyle.Stop,
           ValidationOperator.Between, "=A1>0", null);
       String json = sourceWorkbook.toJson().replace("A1>0", "A1>");
       Workbook importedWorkbook = new Workbook();
       List<JsonError> errors = importedWorkbook.fromJson(json);
       DataValidationJsonError error = (DataValidationJsonError) errors.get(0);
       String errorContent = error.getErrorContent();
       
      Returns:
      The data validation content associated with this error. Returns null if no error content was stored.