YOUSEFUL / DELPHI / COMPONENTS

EAtlasFormulaError

The exception raised by TAtlasWorkbook for formula errors, bad addresses and invalid JSON; Code holds the error code.

Class Unit Atlas.Spreadsheet · Inherits Exception · Product Atlas VCL

Description

Raised by TAtlasWorkbook.Value for formula errors and text cells, by every method that takes an address for an invalid one (#REF!), by SetCellFormat and by the JSON loads. Display catches it and shows Code instead. The message is the code followed by a detail, for example #DIV/0! Division by zero at position 4.

Members

MemberKindWhat it does
CreateconstructorCreates the exception with Code (for example #REF!) and the message Code + ' ' + Detail.
CodepropertyThe error code: #REF!, #CYCLE!, #DIV/0!, #NUM!, #NAME?, #VALUE! or #LIMIT!.

Constructors

Create constructor

constructor Create(const Code, Detail: string);

Creates the exception with Code (for example #REF!) and the message Code + ' ' + Detail.

Properties

Code property

property Code: string read FCode;

The error code: #REF!, #CYCLE!, #DIV/0!, #NUM!, #NAME?, #VALUE! or #LIMIT!.

Examples

Read a cell as a number safely

Prints A1 = 1024, A2: #VALUE! for a text cell and A0: #REF! for an invalid address.

pascal
uses System.SysUtils, Atlas.Spreadsheet;

function CellNumber(Book: TAtlasWorkbook; const Address: string; out Number: Double): Boolean;
begin
  Number := 0;
  try
    Number := Book.Value(Address);
    Result := True;
  except
    on E: EAtlasFormulaError do
    begin
      Writeln(Address, ': ', E.Code); // #DIV/0!, #REF!, #VALUE!, ...
      Result := False;
    end;
  end;
end;

TAtlasWorkbook

Also in Atlas VCL

TAtlasTable · TAtlasGrid · TAtlasValueEdit · TAtlasTree · TAtlasWorkbook · TAtlasSheetGrid · TAtlasPivot · TAtlasInspector · TAtlasRichEdit · TAtlasSpellChecker · TAtlasChart · TAtlasGauge · TAtlasThemer · TAtlasWizard · TAtlasWorkspace · TAtlasCommandBar · TAtlasActionTile · TAtlasTileBoard · TAtlasNavigation · TAtlasMap · TAtlasGraph · TAtlasDiagram · TAtlasPrintDocument · TAtlasSchedule · TAtlasScheduler · TAtlasTaskPlan · TAtlasGantt · TAtlasPdfDocument · TAtlasPdfViewer