XmlMappedRange.Calculate Method

Calculates the value of the XmlMappedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
Function Calculate As Object
Object Calculate()

Return Value

Type: System.Object

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 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
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(
        missing, missing, Excel.XlReferenceStyle.xlA1, missing, missing);               
    Globals.Sheet1.EmployeeSeniorityCell.Value2 = "=YEAR(TODAY())-YEAR("
        + hireDateCellAddress + ")";

    Globals.Sheet1.EmployeeSeniorityCell.Calculate();
}

.NET Framework Security

See Also

Reference

XmlMappedRange Interface

Microsoft.Office.Tools.Excel Namespace