I can't find a way to get my current index position while looping with a foreach in a sheetData.Elements. (Reading an OpenXML document). I had to make my own cell index (cx) and resetting it to 0 when reading a new row.
I tried something like
foreach (Cell c in r.Elements<Cell>().Select((value, i) => new { i, value }))
But obviously it doest work.
My current code :
y=0
foreach (Row r in sheetData.Elements<Row>())
{
dataGridView1.Rows.Add();
cx = 0;
foreach (Cell c in r.Elements<Cell>())
{
dataGridView1.Rows[y].Cells[cx].Value = value;
cx++;
}
y++;
}
Is there a way to make a foreach without my own index.
Thanks !