1、添加引用到你的网站或项目中:
2、一个导出excel的测试程序:
/// <summary>
/// 导出Excel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ExportBtn_Click(object sender, EventArgs e) {
XlsDocument xls = new XlsDocument();
xls.FileName = "TestList.xls";
int rowIndex = 1;
Worksheet sheet = xls.Workbook.Worksheets.Add("测试表");//Sheet名称
Cells cells = sheet.Cells;
Cell cell = cells.Add(1, 1, "编号");
cell.Font.Bold = true;
cell = cells.Add(1, 2, "名称");
cell.Font.Bold = true;
foreach (DataRow row in table.Rows) {
cells.Add(rowIndex, 1, rowIndex);
cells.Add(rowIndex, 2, "名称"+rowIndex);
rowIndex++;
}
xls.Send();
}