Version

ApplyCellFormula Method

Applies a formula to the cell at the specified column index.
Syntax
'Declaration
 
Public Sub ApplyCellFormula( _
   ByVal columnIndex As Integer, _
   ByVal formula As String, _
   Optional ByVal cellReferenceMode As Nullable(Of CellReferenceMode) _
) 
public void ApplyCellFormula( 
   int columnIndex,
   string formula,
   Nullable<CellReferenceMode> cellReferenceMode
)

Parameters

columnIndex
The 0-based index of the cell within the WorksheetRow.
formula
The formula to parse and apply to the cell.
cellReferenceMode
The mode used to interpret cell references in the formula.
Exceptions
ExceptionDescription
System.ArgumentOutOfRangeExceptioncolumnIndex is less than zero or greater than or equal to the number of columns in the worksheet.
System.ArgumentNullExceptionformula is null or empty.
FormulaParseExceptionformula is not a valid formula.
System.InvalidOperationException The cell is part of an array formula or data table which is not confined to just the cell.
System.ComponentModel.InvalidEnumArgumentExceptioncellReferenceMode is not defined in the CellReferenceMode enumeration.
System.InvalidOperationExceptionIf the row was removed from the worksheet.
Remarks

formula is parsed based on the CellReferenceMode of the Workbook to which the row belongs. If the row's Worksheet has been removed from its parent collection, the A1 CellReferenceMode will be used to parse the formula.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also