AFC - Abacus Formula Compiler for Java

Cells And Values In AFC

AFC supports the following types of values in cells:

  • strings
  • numbers (including monetary and percentage values)
  • dates and times
  • booleans

Internally, AFC really only supports two basic data types: numbers and strings. This suffices because Excel internally treats dates, times, and booleans as numbers, too.

For a particular engine compiled by AFC, the numbers are all of the same type. The default is the double type, which is what Excel uses as well. See the tutorial for details on the available numeric types and how to choose one.

Cell References

AFC supports the following styles of cell and range references:

Relative reference
ABC
21.0=C21.0

Absolute references
ABC
36.0=(($C$3 + $C3) + C$3)2.0

Simple name
ABC
43.0=MYCELL3.0

Two names for same cell
ABC
58.0=(_MY_CELL_ + _MY_CELL)4.0

Unconventional names
ABCDEFG
65.0=_MY.CELL.1X5.0
76.0=MY23.43CELL6.0
87.0=_123457.0
9400.0=((((A1B + A1_) + A1_1) + A_1) + A__1)100.090.080.070.060.0

Range with cell references
ABCDE
116.0=SUM( C11:E11 )1.02.03.0

Range name
ABCDE
1215.0=SUM( Range )4.05.06.0

References to other sheets
ABCD
1430.0=(SecondSheet!B1 + CellOnThirdSheet)10.020.0
1530.0='Sheet with spaces'!B130.0
1640.0='Sheet-with-hyphens'!B140.0
1750.0='Sheet''with''quotes'!B150.0

Empty Cells

AFC currently has no proper support for empty cells. It simply treats them like the number zero (0.0). This is usually correct (even for multiplication with *, where Excel treats empty cells as zero too), but fails most noticeably in aggregators like COUNT, AVERAGE, or PRODUCT (where Excel skips empty cells):

Empty cells with +
ABCD
25.0=(C2 + D2)2.03.0
35.0...5.0
46.0...6.0

Empty cells with *
ABCD
66.0=(C6 * D6)2.03.0
70.0...5.0
80.0...6.0

Empty cells with PRODUCT return 0!
ABCD
106.0=PRODUCT( C10, D10 )2.03.0
110.0...5.0Excel says: 5.0
120.0...6.0Excel says: 6.0

Empty cells with SUMIF
ABCDE
1410.0=SUMIF( C14:E14, "=10" )10.0

Formula Errors

AFC throws exceptions or returns error values for Excel error values:

Explicitly entered errors
AB
2!NA#N/AExcel says: #N/A
3!NA=NA()Excel says: #N/A
4!FE#NUM!Excel says: #NUM!
5!FE#VALUE!Excel says: #VALUE!
6!FE#DIV/0!Excel says: #DIV/0!

Errors as inputs
ABCD
7!FE=(C7 + D7)1.0#NUM!Excel says: #NUM!
8!FE...#NUM!2.0Excel says: #NUM!

Actual division by zero
ABC
9!+Inf/AE=(1.0 / C9)0.0Excel says: #DIV/0!

ISNA()
ABC
11true=ISNA( C11 )#N/A
12false...4711.0
13false...#NUM!

ISERR()
ABC
15false=ISERR( C15 )#N/A
16false...4711.0
17true...#NUM!

ISERROR()
ABC
19true=ISERROR( C19 )#N/A
20false...4711.0
21true...#NUM!

COUNTA() is OK
ABCDE
233.0=COUNTA( C23:E23 )#N/A4711.0#NUM

COUNT() is currently broken
ABCDE
243.0=COUNT( C24:E24 )#N/A4712.0#NUMExcel says: 1.0

Numeric Precision

AFC ignores the number of decimal places specified for displaying cell results in Excel. If you want rounded results, you have to use the ROUND() function explicitly. This is consistent with Excel also not limiting the precision on intermediate results.