乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > c# 将指定格式数据添加到excel?(c excel 格式)

c# 将指定格式数据添加到excel?(c excel 格式)

作者:乔山办公网日期:

返回目录:excel表格制作

//建立Excel对象 Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); excel.Application.Workbooks.Add(true);后面可以参考 //生成字段名称 for (int i = 0; i < DGVCustomer.ColumnCount; i++) { excel.Cells[1, i + 1] = DGVCustomer.Columns[i].HeaderText; } //填充数据 for (int i = 0; i < DGVCustomer.RowCount - 1; i++) { for (int j = 0; j < DGVCustomer.ColumnCount; j++) { if (DGVCustomer[j, i].Value == typeof(string)) { excel.Cells[i + 2, j + 1] = "" + DGVCustomer[i, j].Value.ToString(); } else { excel.Cells[i + 2, j + 1] = DGVCustomer[j, i].Value.ToString(); } } } excel.Visible = true;


本文标签:

相关阅读

关键词不能为空
极力推荐
  • 怎样把excel 图的横坐标的文字变正

  • 1、首先在电脑上用2007版excel软件打开目标文件。2、然后在目标表格中,修改图标zhidao横坐内标对应的内容,如图所示。3、然后用鼠标右击图容标,在出现的菜单中点击“选择数据”选

ppt怎么做_excel表格制作_office365_word文档_365办公网