I know this late, but maybe someone will need it in the future. This is not really for performance, but you can store it in a two-dimensional array.
object[,] Values = new object[iGrid.Rows.Count, IGrid.Columns.Count];
for (int i = 0; i < alllogentry.Rows.Count; i++)
{
for (int j = 0; j < alllogentry.Columns.Count; j++)
{
if (alllogentry.Rows[i].Cells[j].Value != null)
{
Values[i, j] = alllogentry.Rows[i].Cells[j].Value.ToString();
}
else
{
Values[i, j] = " ";
}
}
}
This path number contains a number and a string containing a string.
Also pass information through the volume insert so as not to iterate over a cell by cell. That was my code.
String MaxRow = (alllogentry.Rows.Count+6).ToString();
String MaxColumn = ((String)(Convert.ToChar(alllogentry.Columns.Count / 26 + 64).ToString() + Convert.ToChar(alllogentry.Columns.Count % 26 + 64))).Replace('@', ' ').Trim();
String MaxCell = MaxColumn + MaxRow;
worksheet.get_Range("A1", MaxColumn + "1").Font.Bold = true;
worksheet.get_Range("A1", MaxColumn + "1").VerticalAlignment = XlVAlign.xlVAlignCenter;
worksheet.get_Range("A7", MaxCell).Value2 = Values;
source
share