您好,
导出Excel2003
xls.FileFormat = FileFormat.Xls97Plus;这句是重点代码
不然打开后中文就是乱码?
- public void ProcessRequest(HttpContext context)
- {
- var filePath = "/Reports" + context.Request.FilePath;
- filePath = filePath.Remove(filePath.Length - 4); // cut ".csv"
- var reportPath = context.Server.MapPath(filePath);
- var paramValue = context.Request.QueryString["paramValue"];
- var report = new PageReport(new FileInfo(reportPath));
-
- context.Response.ContentType = "application/excel";
- context.Response.Clear();
- context.Response.AddHeader("content-disposition", "attachment;filename=test.Xls");
- XlsExport xls = new XlsExport();
- System.IO.MemoryStream memStream = new System.IO.MemoryStream();
- xls.FileFormat = FileFormat.Xls97Plus;
- xls.Export(report.Document, memStream);
- context.Response.BinaryWrite(memStream.ToArray());
- context.Response.End();
- }
复制代码 传输参数的参考博客:
http://blog.gcpowertools.com.cn/ ... er_MultiValues.aspx
|