[]
        
(Showing Draft Content)

FormulaJsonError

Class FormulaJsonError

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

public class FormulaJsonError extends JsonError
Represents a formula-related error in imported JSON content.

This class extends JsonError and stores the worksheet name, row index, column index, and formula text associated with a formula that could not be processed. It is typically used to describe formula errors reported while loading workbook data from JSON.


 Workbook sourceWorkbook = new Workbook();
 sourceWorkbook.getWorksheets().get(0).getRange("C2").setFormula("=SUM(A1:A2)");
 String json = sourceWorkbook.toJson().replace("SUM(A1:A2)", "SUM(A1:)");
 Workbook importedWorkbook = new Workbook();
 List<JsonError> errors = importedWorkbook.fromJson(json);
 FormulaJsonError error = (FormulaJsonError) errors.get(0);
 String worksheetName = error.getWorksheetName();
 String formula = error.getFormula();
 
  • Constructor Details

    • FormulaJsonError

      public FormulaJsonError(String errorMessage, String worksheetName, int row, int column, String formula)
      Constructs a new FormulaJsonError object with the specified error message, worksheet name, row, column, and formula.
      Parameters:
      errorMessage - The error message associated with the formula error.
      worksheetName - The name of the worksheet where the formula error occurred.
      row - The row index where the formula error occurred.
      column - The column index where the formula error occurred.
      formula - The formula that caused the error.
  • Method Details

    • getWorksheetName

      public String getWorksheetName()
      Gets the name of the worksheet where the formula error occurred.

      This value identifies the worksheet associated with the invalid or unprocessed formula in the imported JSON content.

      
       Workbook sourceWorkbook = new Workbook();
       sourceWorkbook.getWorksheets().get(0).getRange("C2").setFormula("=SUM(A1:A2)");
       String json = sourceWorkbook.toJson().replace("SUM(A1:A2)", "SUM(A1:)");
       Workbook importedWorkbook = new Workbook();
       List<JsonError> errors = importedWorkbook.fromJson(json);
       FormulaJsonError error = (FormulaJsonError) errors.get(0);
       String worksheetName = error.getWorksheetName();
       
      Returns:
      The worksheet name associated with this formula error, or null if no worksheet name was provided.
    • getRow

      public int getRow()
      Gets the row index where the formula error occurred.

      This value identifies the row associated with the invalid or unprocessed formula in the imported JSON content.

      
       Workbook sourceWorkbook = new Workbook();
       sourceWorkbook.getWorksheets().get(0).getRange("C2").setFormula("=SUM(A1:A2)");
       String json = sourceWorkbook.toJson().replace("SUM(A1:A2)", "SUM(A1:)");
       Workbook importedWorkbook = new Workbook();
       List<JsonError> errors = importedWorkbook.fromJson(json);
       FormulaJsonError error = (FormulaJsonError) errors.get(0);
       int row = error.getRow();
       
      Returns:
      The zero-based row index of the formula error location.
    • getColumn

      public int getColumn()
      Gets the column index where the formula error occurred.

      This value identifies the column associated with the invalid or unprocessed formula in the imported JSON content.

      
       Workbook sourceWorkbook = new Workbook();
       sourceWorkbook.getWorksheets().get(0).getRange("C2").setFormula("=SUM(A1:A2)");
       String json = sourceWorkbook.toJson().replace("SUM(A1:A2)", "SUM(A1:)");
       Workbook importedWorkbook = new Workbook();
       List<JsonError> errors = importedWorkbook.fromJson(json);
       FormulaJsonError error = (FormulaJsonError) errors.get(0);
       int column = error.getColumn();
       
      Returns:
      The zero-based column index of the formula error location.
    • getFormula

      public String getFormula()
      Gets the formula text associated with this JSON import error.

      This method returns the formula string that could not be processed when the workbook data was loaded from JSON.

      
       Workbook sourceWorkbook = new Workbook();
       sourceWorkbook.getWorksheets().get(0).getRange("C2").setFormula("=SUM(A1:A2)");
       String json = sourceWorkbook.toJson().replace("SUM(A1:A2)", "SUM(A1:)");
       Workbook importedWorkbook = new Workbook();
       List<JsonError> errors = importedWorkbook.fromJson(json);
       FormulaJsonError error = (FormulaJsonError) errors.get(0);
       String formula = error.getFormula();
       
      Returns:
      The formula text associated with this error, or null if no formula was provided.