Microsoft.Office.Interop.Excel.Application App;
Microsoft.Office.Interop.Excel.Worksheet Worksheet;
Microsoft.Office.Interop.Excel.Workbook Wbook;
App = new Microsoft.Office.Interop.Excel.Application();
App.Visible = true;
Wbook = (Microsoft.Office.Interop.Excel.Workbook)(App.Workbooks.Add(System.Reflection.Missing.Value));
Worksheet = Wbook.ActiveSheet;
for (int i = 0; i < dataGridView.RowCount -1 ; i++)
{
Worksheet.Cells[1, i + 1] = dataGridView.Columns[i].HeaderText;
}
참고사항
Code Snippet
public static void RunExcel()
{
Excel._Application xl = new Excel.ApplicationClass();
xl.Visible = true;
Excel.Workbook wk = (Excel.Workbook)(xl.Workbooks.Add(System.Reflection.Missing.Value));
}