在VS2013中使用水晶报表

又遇到了在B/S系统中打印,打印格式要求比较高,打印出的效果要求高大上。用VS2013中微软自带的报表,实在难以实现应用的效果,主要问题表现在:

1.不能插入用Word做好的打印模板,自己按照模板来做感觉比较费事,实现不了Word的打印效果,一旦打印模板改变,调整格式比较麻烦。

2.在火狐、谷歌浏览器中打印按钮不显示。

想试试水晶报表,无奈VS2013中已经不集成该报表了。需要单独下载安装http://scn.sap.com/docs/DOC-7824。大家可以根据自己的VS版本下载合适的水晶报表插件。但是一定要注意下载exe可安装文件,而不是msi安装文件,否则VS里面找不到添加水晶报表的项。即下图中红色方框内的说明。同时也要下载一个clickonce32/64,在服务器部署是需要。

image

安装好之后,在VS的新建项中发现了熟悉的Crystal Reports如下图:

image

在详细资料处【右键】--【插入】--【OLE对象】--【由文件创建】选中要打印的模板。拖动鼠标,放置。

在字段资源管理器中【参数字段】--【右键】--【新建参数】。

image

把参数拖放到要动态获取数据的地方。

image

新建Web窗体,拖放CrystalReportViewer控件,设置相关属性。其中如果不需要左侧的组树,需要设置ToolPanelView=“None”。这是与当时在VS2008中用水晶报表不同的地方。

在页面后台代码动态设置字段值。如下:

protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               ReportDocument testReport = new ReportDocument();
               //取到报表文件物理路径 
               string reportPath = Server.MapPath("~/CrystalReport1.rpt");
               //加载报表文件 
               testReport.Load(reportPath);

 

               this.CrystalReportViewer1.ReportSource = testReport;

               ParameterFields pfs = new ParameterFields();
               ParameterField pf = new ParameterField();
               ParameterDiscreteValue pv = new ParameterDiscreteValue();


               pf.ParameterFieldName = "SQR";
               pv.Value = "一衣孤行";
               pf.CurrentValues.Add(pv);
               pfs.Add(pf);

 

               this.CrystalReportViewer1.ParameterFieldInfo = pfs;
           }
       } 

 

在VS中运行调试,打印模板不见了,只有“图像”二字,结果如下:

image

右键图片属性,看到图片的路径是:http://localhost:/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_3ab921d0-cd7d-4fb9-a724-fd12c580b18d.png。问题是我的项目中也没有CrystalImageHandler.aspx啊。新增空白CrystalImageHandler.aspx页面。重新运行,OK。效果如下:

SNAGHTML1c15394

在IIS中发布。首先出现如下错误:

未能加载文件或程序集“log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304”或它的某一个依赖项。系统找不到指定的文件。

问题是我也没用到log4net啊。按照网上的方法把C:\Windows\assembly\GAC_32\log4net\1.2.10.0__692fbea5521e1304\log4net.dll (不同的版本log4net的版本可能不同,可以用dos命令符在C:\Windows\assembly文件夹下用dir命令逐级找到)copy出来,放到部署之后的程序bin文件夹下。刷新页面,出现如下错误:

未能加载文件或程序集“log4net”或它的某一个依赖项。试图加载格式不正确的程序。

这个错误很熟悉吧,64位操作系统IIS应用程序池未启用32位应用程序,设为True。刷新页面,出现如下错误:

不支持的操作。无法在 C++ 堆栈中打开由 JRC 引擎处理的文档。

发现在发布的时候VS不会把rpt文件发布过来,直接把rpt拷贝过来。刷新页面,OK了。

 

转载于:https://www.cnblogs.com/shunliy/p/4624836.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
7-5 共7个压缩包(只有50M上传权限) Create rich reports within the familiarity of your Visual Studio development environment – for free Hit your report development deadlines and come in under budget without leaving Microsoft Visual Studio. Our report design software installs directly into Visual Studio. With this fully functional – and free software, you'll spend less and save time developing rich, interactive reports. Save time using powerful report creation, integration, and delivery tools Deliver interactive, graphical reports on any device through an XML Web services model Distribute highly formatted reports in rich-client Windows environments Enjoy flexible data access with support for over 35 data sources, major browsers and operating systems Extend your application with seamless report integration into WPF applications Seamless upgrade to SAP Crystal Reports 2011 for added report functionality Download SAP Crystal Reports, developer version for Microsoft Visual Studio now › Share 2 Features and Functionality Collapse All Features and Functionality Learn more about the features and functions of SAP Crystal Reports, developer version for Microsoft Visual Studio. Powerful designer features for creating rich reports Flexible Windows and Web application features support development ASP.NET features support your ASP development efforts Broad data access enables multiple sources and dynamic data output Platform features provide support and management for SAP Crystal Reports projects Get all the details on SAP Crystal Reports, developer version for Microsoft Visual Studio features › Less Technical & License Resources Discover if SAP Crystal Reports, developer version for Microsoft Visual Studio is right for you. Get started by reviewing the technical, data access and license details. Access virtually any data sources via ODBC, OLE DB or native connections Licensed for report design, runtime distribution and report viewer distribution Add reporting to thick client and intern

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值