林经理,您好 ! 非常不好意思!您反馈的导出的WORD和EXCEL不支持WPS及不支持低版本OFFICE的问题。 我这边现在给你提供一种解决问题思路。
- 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();
- <font color="#ff0000"> xls.FileFormat = FileFormat.Xls97Plus; 关键代码</font>
- xls.Export(report.Document, memStream);
- context.Response.BinaryWrite(memStream.ToArray());
- context.Response.End();
- }
复制代码具体可参考附件的demo
|