资 源 简 介
导出Excel组件(B/S或C/S都可以用)
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") //这里的文件名可以任意定义 -Excel export component (B/S or C/S can be used) using GemBox.ExcelLite // reference document 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