## Range.GetEnumerator method

获取此 Range 中单元格的枚举器。

```csharp
public IEnumerator GetEnumerator()
```

### 返回值

单元格枚举器

### 评论

返回的Enumerator遍历元素时，cell collection 不应该被修改（例如会导致新的Cell/Row被实例化或现有的Cell/Row被删除的操作）。 否则枚举器可能无法正确遍历所有cell （某些元素可能会被重复遍历或跳过）。

### 例子

```csharp
[C#]
Workbook workbook = new Workbook("template.xlsx");
Cells cells = workbook.Worksheets[0].Cells;

IEnumerator en = cells.CreateRange("B2:C3").GetEnumerator();
while (en.MoveNext())
{
    Cell cell = (Cell)en.Current;
    Console.WriteLine(cell.Name + ": " + cell.Value);
}
```

### 也可以看看

* class [Range](../../range)
* 命名空间 [Aspose.Cells](../../range)
* 部件 [Aspose.Cells](../../../)

<!-- DO NOT EDIT: generated by xmldocmd for Aspose.Cells.dll -->
