There's an [int Row, int Col]
indexer on Cells
(type ExcelRange
), so you can use ws.Cells[i, 0]
.
int i = 1;
foreach (var item in items)
{
ws.Cells[i, 0].Value =item.Text;
i++;
}
Frage
I am using Epplus to write out a collection into an excel file. Currently I am incrementing rows by manually manipulating the cell number.(ws is an instance of ExcelWorkSheet)
int i = 1;
foreach (var item in items)
{
ws.Cells["A"+i.ToString()].Value =item.Text;
i++;
}
Instead of adding number to cell name is there a better way to handle this? Something like
int i = 1;
foreach (var item in items)
{
ws.Row[i].Cells[0]=item.Text;
i++;
}
Lösung
There's an [int Row, int Col]
indexer on Cells
(type ExcelRange
), so you can use ws.Cells[i, 0]
.
int i = 1;
foreach (var item in items)
{
ws.Cells[i, 0].Value =item.Text;
i++;
}