Microsoft.Office.Interop.Excel.ApplicationClass Excelapp = new Microsoft.Office.Interop.Excel.ApplicationClass(); Excelapp.Application.Workbooks.Add(); int IndiceColumn = 0; foreach (DataGridViewColumn col in table.Columns) { IndiceColumn++; Excelapp.Cells[1, IndiceColumn] = col.Name; } int IndeceFile = 0; foreach (DataGridViewRow r in table.Rows) { { IndeceFile++; IndiceColumn = 0; foreach (DataGridViewColumn col in table.Columns) { IndiceColumn++; Excelapp.Cells[IndeceFile + 1, IndiceColumn] = r.Cells[col.Name].Value; } } // Excelapp.Visible = true; Excelapp.ActiveWorkbook.SaveCopyAs(saveFileDialog1.FileName.ToString()); Excelapp.ActiveWorkbook.Saved = true; Excelapp.Quit();
Excel->Workbooks[index]->Worksheets[index]->Cells[index, index]
Excel ExApp = New Excel;Workbook wbk = ExApp.Workbooks.Add();Worksheet wsh = wbk.Worksheets["WorksheetName"];wsh.Cells[index, index] = "StringValue";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)