Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
ExcelApp.Application.Workbooks.Add(System.Type.Missing);
ExcelApp.Visible = true;
for (int i = 0; i < dataGridViewProduct.ColumnCount; i++)
{
for (int j = 0; j < dataGridViewProduct.RowCount; j++)
{
ExcelApp.Cells[j + 2, i + 1] = dataGridViewProduct[i, j].Value;
}
}
Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
ExcelApp.Application.Workbooks.Add(System.Type.Missing);
ExcelApp.Visible = true;
for (int i = 0; i < dataGridViewProduct.ColumnCount; i++)
{
for (int j = 0; j < dataGridViewProduct.RowCount; j++)
{
if (dataGridViewProduct[i, j].Value == null)
ExcelApp.Cells[j + 2, i + 1] = " ";
else
{
ExcelApp.Cells[j + 2, i + 1] = dataGridViewProduct[i, j].Value.ToString();
}
}
}