110,571
社区成员
发帖
与我相关
我的任务
分享
NpoiExcelHelper nopi = new NpoiExcelHelper();
DataTable table = nopi.ListToDataTable(list); --list是IList类型
nopi.Write(table, "", "sheetName", strFieldsName, strFieldsTitle, --strFieldsName是list的对象名,strFieldsTitle是表头
tj, '',"导出.xls",maintainStaffNameDic); --tj是用来sheet2的统计信息的,maintainStaffNameDic是用来sheet2的信息之一.
public void Write(DataTable table, string headerText, string sheetName,
string[] columnName, string[] columnTitle, MalfunctionHandleTJ tj,
string headerText1, string fileName, Dictionary<string, int> maintainStaffNameDic)
{
HttpContext context = HttpContext.Current;
context.Response.ContentType = "application/vnd.ms-excel";
context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", HttpUtility.UrlEncode(fileName, Encoding.UTF8)));
context.Response.Clear();
HSSFWorkbook hssfworkbook = GenerateData(table, headerText, sheetName,
columnName, columnTitle, tj, headerText1, maintainStaffNameDic);
context.Response.BinaryWrite(WriteToStream(hssfworkbook).GetBuffer());
context.Response.End();
}
NpoiExcelHelper nopi = new NpoiExcelHelper();
DataTable table = nopi.ListToDataTable(list);
nopi.Write(table, "", "sheetName", strFieldsName, strFieldsTitle, "导出.xls");
public void Write(DataTable table, string headerText, string sheetName,
string[] columnName, string[] columnTitle, string fileName)
{
HttpContext context = HttpContext.Current;
context.Response.ContentType = "application/vnd.ms-excel";
context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", HttpUtility.UrlEncode(fileName, Encoding.UTF8)));
context.Response.Clear();
HSSFWorkbook hssfworkbook = null;
hssfworkbook = GenerateData(table, headerText, sheetName,
columnName, columnTitle);
context.Response.BinaryWrite(WriteToStream(hssfworkbook).GetBuffer());
context.Response.End();
}