songxianbin_xxx 发表于 2018-1-12 14:09:29

中文乱码已经参数的问题

本帖最后由 gw0506 于 2018-1-30 09:55 编辑

这个是上次你们发给我们的demo用来导出excel03格式的但是参数这么传表没写,而且导出的时候会中文乱码,请帮忙解决一下

KearneyKang 发表于 2018-1-12 15:12:00


您好,
导出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/post/ActiveReports_Parameter_MultiValues.aspx

songxianbin_xxx 发表于 2018-1-15 13:03:15

KearneyKang 发表于 2018-1-12 15:12
您好,
导出Excel2003
xls.FileFormat = FileFormat.Xls97Plus;这句是重点代码


你现在这个报表是没有参数的    我前台怎么传报表参数

songxianbin_xxx 发表于 2018-1-15 13:03:19

本帖最后由 songxianbin_xxx 于 2018-1-15 13:27 编辑

1

KearneyKang 发表于 2018-1-15 14:39:16

您好!
这个博客里就讲了参数传递,您参考下
http://blog.gcpowertools.com.cn/ ... er_MultiValues.aspx

KearneyKang 发表于 2018-1-29 16:08:28

您好!
您的office版本是多少,还有您最好可以把能反馈您问题的demo发过来,我这边给验证下。

songxianbin_xxx 发表于 2018-1-31 11:53:59

KearneyKang 发表于 2018-1-29 16:08
您好!
您的office版本是多少,还有您最好可以把能反馈您问题的demo发过来,我这边给验证下。

office是03版本的,demo上面已经发过了

KearneyKang 发表于 2018-1-31 13:58:29

好的1我去调试下

KearneyKang 发表于 2018-1-31 14:51:25

您好!
您的demo中的xls.FileFormat = FileFormat.Xls95;这样导出的Excel就是会出现在乱码!我前面就告诉你们需要把   xls.FileFormat = FileFormat.Xls97Plus;换成这样,就好了。
具体你可以参考附件






songxianbin_xxx 发表于 2018-2-2 09:54:43

我们要导出office2003的格式,FileFormat.Xls97Plus这个是吗?
页: [1] 2
查看完整版本: 中文乱码已经参数的问题