Microsoft Office Tutorials and References
In Depth Information
User-Defined Functions (UDFs)
array that represents the object that was passed in. One or more rows are passed in, and the same rows
are returned.
public object[,] Return2dObjectArray(object[,] xlRange)
return (xlRange)
In Excel, you call the Return2dObjectArray method by entering the following code into cell C11. To
create the array formula, select cells C11:E15, press F2, and then press Ctrl+Shift+Enter. Excel
automatically inserts the formula between {} (curly braces). The C11:E15 range represents the cells where the
object[,] returned from Return2dObjectArray is applied. Excel evaluates the method as #NAME? .
The example noted here uses H8:J12 as the argument to pass in. After Return2dObjectArray returns,
C11:E15 contains the same values as H8:J12 .
Creating a UDF
This section focuses on creating an Excel Services UDF, deploying the managed UDF assembly to the
ECS, and calling the UDF methods from an Excel workbook. Here are a few prerequisites that must be
met before you get started:
Microsoft Office SharePoint Server 2007 must be available.
Excel Services must be set up and ready to load workbooks.
There must be an Excel 12 client and an ECS trusted location where at least View permissions
are set.
A Microsoft .Net Framework 2.0 development environment must be set up (The procedures
use Microsoft Visual Studio 2005.)
Creating the C# Class Library
Follow these steps to launch Visual Studio and create the C# class library:
Start Visual Studio.
Select File
Project to open the New Project dialog box.
In the Project Types frame, expand the Visual C# node and select Windows. In the Templates
frame, select Class Library.
In the Name field, enter xlUdf .
Set the Location field to the location where you want to create the solution.
Click OK to create the library. The New Project dialog box closes, and Visual Studio opens the
xlUdf solution with Class1.cs open and visible. The namespace is xlUdf.
Search JabSto ::

Custom Search