YOUSEFUL / DELPHI / COMPONENTS
EAtlasFormulaError
The exception raised by TAtlasWorkbook for formula errors, bad addresses and invalid JSON; Code holds the error code.
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
| Member | Kind | What it does |
|---|---|---|
Create | constructor | Creates the exception with Code (for example #REF!) and the message Code + ' ' + Detail. |
Code | property | The 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.
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;Related
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