DataGridView中的数据转换为Excel
using GemBox.ExcelLite; //引用文件
点击下载引用文件ExcelFile excelFile = new ExcelFile();
ExcelWorksheet sheet = excelFile.Worksheets.Add("WolfSpider");
int columns = dataGridView1.Columns.Count;
int rows = dataGridView1.Rows.Count;
for (int j = 0; j < columns;j++ )
{
sheet.Cells[0, j].Value = dataGridView1.Columns[j].HeaderText;
}
for (int i = 1; i <= rows; i++)
{
for (int j = 0; j < columns; j++)
{
sheet.Cells[i, j].Value = dataGridView1[j, i-1].Value;
}
}
excelFile.SaveXls("./guyun.xls"); //这里的文件名可以任意定义
(AD:
进口轴承 jack jones 火狐浏览器下载 杰克琼斯 )
{tag_点击标签样式三}