XmlMappedRange.Calculate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Calculates the value of the XmlMappedRange control.
public:
System::Object ^ Calculate();
public object Calculate ();
abstract member Calculate : unit -> obj
Public Function Calculate () As Object
Returns
Examples
The following code example uses the Calculate method to calculate the value of the formula in the EmployeeSeniorityCell
XmlMappedRange control on Sheet1
. To run this code example, you must add an XML map to your workbook based on the Employee XML schema and map the schema elements from this XML map to cells on a worksheet. For example, you can use the schema from Walkthrough: Binding Content Controls to Custom XML Parts and modify it by adding a seniority element of type integer to the employee element.
Note
Typically, you populate the XmlMappedRange control from an XML file. This example hard-codes the value of the control for simplicity.
private void CalculateXMLMappedRange()
{
Globals.Sheet1.EmployeeNameCell.Value2 = "Karina Leal";
Globals.Sheet1.EmployeeHireDateCell.Value2 = "1999-04-01";
Globals.Sheet1.EmployeeTitleCell.Value2 = "Manager";
string hireDateCellAddress =
Globals.Sheet1.EmployeeHireDateCell.Cells.get_Address(
Excel.XlReferenceStyle.xlA1);
Globals.Sheet1.EmployeeSeniorityCell.Value2 = "=YEAR(TODAY())-YEAR("
+ hireDateCellAddress + ")";
Globals.Sheet1.EmployeeSeniorityCell.Calculate();
}
Private Sub CalculateXMLMappedRange()
Globals.Sheet1.EmployeeNameCell.Value2 = "Karina Leal"
Globals.Sheet1.EmployeeHireDateCell.Value2 = "1999-04-01"
Globals.Sheet1.EmployeeTitleCell.Value2 = "Manager"
Dim hireDateCellAddress As String = _
Globals.Sheet1.EmployeeHireDateCell.Cells.Address
Globals.Sheet1.EmployeeSeniorityCell.Value2 = "=YEAR(TODAY())-YEAR(" _
+ hireDateCellAddress + ")"
Globals.Sheet1.EmployeeSeniorityCell.Calculate()
End Sub