officefileapi-devexpress-dot-spreadsheet-dot-worksheet-70f73a2b.md
Gets the existing cells in the worksheet.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
IEnumerable<Cell> GetExistingCells()
Function GetExistingCells As IEnumerable(Of Cell)
| Type | Description |
|---|---|
| IEnumerable<Cell> |
An enumerator that supports iteration over the cell collection.
|
Use the GetExistingCells method to iterate through the collection of existing cells in the worksheet. The GetExistingCells collection includes the following cells:
The following code snippet iterates through existing cells to remove the name prefix of the user-defined function (UDF) of the Excel XLL Add-in. You can implement your own user-defined function instead.
IEnumerable<DevExpress.Spreadsheet.Cell> existingCells = spreadsheetControl1.ActiveWorksheet.GetExistingCells();
spreadsheetControl1.Document.BeginUpdate();
foreach (DevExpress.Spreadsheet.Cell cell in existingCells)
{
if (cell.HasFormula)
// The worksheet references functions from the DiscountXLL.MyFunctions xll Add-in.
// The name prefix is removed leaving only the function name.
cell.Formula = cell.Formula.Replace("_xll.DiscountXLL.MyFunctions.", string.Empty);
}
spreadsheetControl1.Document.EndUpdate();
Dim existingCells As IEnumerable(Of DevExpress.Spreadsheet.Cell) = spreadsheetControl1.ActiveWorksheet.GetExistingCells()
spreadsheetControl1.Document.BeginUpdate()
For Each cell As DevExpress.Spreadsheet.Cell In existingCells
If cell.HasFormula Then
' The worksheet references functions from the DiscountXLL.MyFunctions xll Add-in.
' The name prefix is removed leaving only the function name.
cell.Formula = cell.Formula.Replace("_xll.DiscountXLL.MyFunctions.", String.Empty)
End If
Next cell
spreadsheetControl1.Document.EndUpdate()
See Also