js
function PrintData()
{
document.location.href = setter.host + “/dwlsys/ExportdwList?hzlb=1”;
}
///
/// 导出单位信息
///
///
[HttpGet]
public FileContentResult ExportdwList(QueryLsYs model)
{
string a = Request.Headers[“token”];
dwlsysProvider provider = new dwlsysProvider();
DataTable dt = provider.ExportdwList(model);
dt.TableName = "DanWeiHuiZong";
WorkbookDesigner designer = new WorkbookDesigner();
Workbook workbook = new Workbook(Server.MapPath("~/tmpl/DanWeiHuiZong.xls"));
var tbname = "单位汇总";
designer.Workbook = workbook;
designer.SetDataSource(dt);
designer.SetDataSource("caption", tbname);
designer.Process();
System.IO.MemoryStream ms = workbook.SaveToStream();
return File(ms.ToArray(), "application/vnd.ms-excel", tbname + ".xls");
}
模板文件
&=$caption
&=DanWeiHuiZong.dwmc