GetEnumerator

Cells.GetEnumerator method

获取单元格枚举器。

public IEnumerator GetEnumerator()

返回值

单元格枚举器

评论

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

例子

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

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

也可以看看