Error Show like this when
export databse to excel file
"The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?"
if (dataGridView.Rows.Count > 0)
{
Microsoft.Office.Interop.Excel.ApplicationClass XcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
XcelApp.Application.Workbooks.Add(Type.Missing);
for (int i = 1; i < dataGridView.Columns.Count + 1; i++)
{
XcelApp.Cells[1, i] = dataGridView.Columns[i - 1].HeaderText;
}
for (int i = 0; i < dataGridView.Rows.Count; i++)
{
for (int j = 0; j < dataGridView.Columns.Count; j++)
{
XcelApp.Cells[i + 2, j + 1] = dataGridView.Rows[i].Cells[j].Value.ToString();
}
}
XcelApp.Columns.AutoFit();
XcelApp.Visible = true;
}
{
Microsoft.Office.Interop.Excel.ApplicationClass XcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
XcelApp.Application.Workbooks.Add(Type.Missing);
for (int i = 1; i < dataGridView.Columns.Count + 1; i++)
{
XcelApp.Cells[1, i] = dataGridView.Columns[i - 1].HeaderText;
}
for (int i = 0; i < dataGridView.Rows.Count; i++)
{
for (int j = 0; j < dataGridView.Columns.Count; j++)
{
XcelApp.Cells[i + 2, j + 1] = dataGridView.Rows[i].Cells[j].Value.ToString();
}
}
XcelApp.Columns.AutoFit();
XcelApp.Visible = true;
}

Rafnas T PPosted Jul 7, 2017, 3:40 AM
Jyoti JodhaPosted Jul 7, 2017, 3:28 AM
Amit GuptaPosted Jul 7, 2017, 2:47 AM
Jyoti JodhaPosted Jul 7, 2017, 2:31 AM
Rafnas T PPosted Jul 7, 2017, 2:19 AM
Jyoti JodhaPosted Jul 7, 2017, 2:14 AM
Rafnas T P
Rafnas T PPosted Jul 7, 2017, 2:11 AM
tick click ok.
Jyoti JodhaPosted Jul 7, 2017, 2:03 AM
Amit GuptaPosted Jul 7, 2017, 1:53 AM