This section discusses the data types, type errors, arrays, ranges, and parameter arrays for argument data types that Excel Services supports.
The following table shows the pairing between an Excel type value that is passed to a UDF argument and a supported .NET Framework type argument.
The table explains how each pair behaves, that is, what gets passed to the UDF in the argument. If a pair is not supported, the table shows the cell error that is returned to Excel. If the .NET Framework type is not supported, the UDF is not called.
For example, if you pass an Excel Double value type to an Excel Services UDF argument for the DateTime value type, the table shows how Excel Services converts the Excel representation of date/time into the .NET Framework representation. In this example, Double is converted to DateTime.
As another example, the combination of a UDF argument of type DateTime with an Excel cell of type Error (a cell that contains #NUM, #VALUE, #DIV/0, and so on) returns a #VALUE error as the UDF return value, because the Excel cell and the UDF argument type are incompatible.
Note: |
|---|
|
Boxing and unboxing enable value types to be treated as objects. For more information about boxing and unboxing, see Boxing and Unboxing.
|
Table 1. Supported Excel types and UDF arguments
1. Types are in the System namespace. These are the only supported argument types.
2. The term "All numeric" refers to the following types: Double, Single, Int32, UInt32, Int16, UInt16, Byte, Sbyte. Specifically, Int64 and UInt64 are not supported types.
3. Date/time in Excel is a Double internally, but the representation (algorithm to encode date/time as Double) is different from the .NET Framework representation, and conversion is necessary. Therefore, UDF arguments support DateTime as an explicit type, and Excel Services convert any Excel Double into a .NET DateTime when the argument is of type DateTime (assuming that the Excel Double is actually a date/time value).
4. Scalar object arguments are not supported; only one-dimensional or two-dimensional object arrays are supported (see the "Arrays and Ranges" later in this article). This table row defines only how each cell in the range that is passed into the array is handled.