用C#将Datagridview的内容存入Excel表
2020-12-13 14:53
标签:datagridview io os 使用 for sp on cti 代码 使用如下代码,可将Datagridview的内容存入Excel表中: using Microsoft.Office.Core; Excel.Application excelApp = new Excel.Application(); excelApp.Application.Workbooks.Add(true); object misValue = System.Reflection.Missing.Value; if(File.Exists("D:\\List.xls")) { File.Delete("D:\\List.xls"); excelApp.ActiveWorkbook.SaveAs(@"D:\List.xls", misValue, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); } else { excelApp.ActiveWorkbook.SaveAs(@"D:\List.xls", misValue, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); } string myPath = "D:\\List.xls"; excelApp.Workbooks.Open(myPath); for (int i = 0; i
{ for (int j = 0; j
{ excelApp.Cells[j + 2, i + 1] = dataGridView1[i, j].Value.ToString(); } excelApp.Cells[1, i + 1] = dataGridView1.Columns[i].HeaderText; } excelApp.Visible = true; 用C#将Datagridview的内容存入Excel表 标签:datagridview io os 使用 for sp on cti 代码 原文地址:http://www.cnblogs.com/Laurent/p/4067204.html
using Excel= Microsoft.Office.Interop.Excel;
上一篇:js正則表達式语法