Formula Types
Formula takes values and transform them to other values. There is only a limited number of types for the value.
Each value in a formula evaluation has one of following types:
- blank - A value of an empty cell or a missing argument of a function. Empty string is not blank!, it is basically a missing value type.
- logical - a bool value with either true or false value.
- number - a double precision floating point number
- text - a text of any length, even empty string.
- error - one of standard excel errors, like
#DIV/0!
. - array - a 1D/2D array where each element is a logical/number/text/error value. Array has always at least 1 element.
- reference - A reference to a cells of a workbook. Reference always has at least one cell. A reference is composed of one or more areas. Area is a continuous rectangular range of cells. Area can have associated workbook, but that is optional (
A1:B2
will be turned into an area without a workbook). If the workbook is needed and not present, the context workbook is used.
There is no type for TimeSpan
or DateTime
. Both are represented by a number.
If a type is not suitable, CalcEngine can coerce convert value of a type to a different type. Not all conversions are possible, failed conversion will create the #VALUE!
error.
Some conversions are dependent on a culture, e.g. text "1,25" can be converted to a number 1.25
in Czech culture but fails with #VALUE!
with US culture.
A1 is a blank cell. N/A
means conversion is not available, thus result is #VALUE!
Conversion from a value to blank value is not possible, so it is omitted from conversion table.
Conversion table is a work in progress
From\To | logical | number | text | error | array | reference |
---|---|---|---|---|---|---|
blank | false | 1.0 | empty string | N/A | N/A | N/A |
IF(A1,"blank is true", "false") |
COS(A1) results into 1, which means the value of COS was 0 |
IF(A1="",1,2) is 1 |
||||
number | 0 is false, other numbers are true | identity | convert number to text using culture | N/A | N/A | N/A |
text | ||||||
error | ||||||
array | ||||||
reference |
- How do I deliver an Excel file in ASP.NET?
- Does it support Excel 2003 and prior formats (.xls)?
- How can I insert an image?
- Text with numbers are getting converted to numbers, what's up with that?
- How do I get the result of a formula?
- Data Types
- Creating Multiple Worksheets
- Organizing Sheets
- Loading and Modifying Files
- Using Lambda Expressions
- Cell Values
- Workbook Properties
- Using Formulas
- Evaluating Formulas
- Creating Rows And Columns Outlines
- Hide Unhide Rows And Columns
- Freeze Panes
- Copying Worksheets
- Using Hyperlinks
- Data Validation
- Hide Worksheets
- Sheet Protection
- Tab Colors
- Conditional Formatting
- Pivot Table example
- Sparklines
- Copying IEnumerable Collections
- Inserting Data
- Inserting Tables
- Adding DataTable as Worksheet
- Adding DataSet
- Styles - Alignment
- Styles - Border
- Styles - Fill
- Styles - Font
- Styles - NumberFormat
- NumberFormatId Lookup Table
- Style Worksheet
- Style Rows and Columns
- Using Default Styles
- Using Colors
- ClosedXML Predefined Colors
- Excel Indexed Colors
- Using Rich Text
- Using Phonetics
- Defining Ranges
- Merging Cells
- Clearing Ranges
- Deleting Ranges
- Multiple Ranges
- Shifting Ranges
- Transpose Ranges
- Named Ranges
- Accessing Named Ranges
- Copying Ranges
- Using Tables
- Sorting Data
- Selecting Cells and Ranges
- Row Height and Styles
- Selecting Rows
- Inserting Rows
- Inserting and Deleting Rows
- Adjust Row Height and Column Width to Contents
- Row Cells
- Column Width and Styles
- Selecting Columns
- Inserting Columns
- Inserting and Deleting Columns
- Adjust Row Height and Column Width to Contents
- Column Cells
- Pages Tab
- Paper Size Lookup Table
- Margins Tab
- Headers and Footers Tab
- Sheet Tab
- Print Areas and Page Breaks