使用FastReport.Service.dll创建Web报表服务

本文介绍了如何利用FastReport的新特性——FastReport.Service.dll,在.NET Framework 4.0及以上版本的ASP.NET Web Application项目中创建Web报表服务。通过几个简单的步骤,包括添加必要的引用库、配置ReportService.svc文件以及设置报表文件路径和连接字符串,可以实现基于Web服务的Web报表应用。在服务器部署时,确保相关DLL文件位于/bin目录下,并在Visual Studio中配置服务引用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  最新版本的FastReport .Net推出了WCF服务库——FastReport.Service.dll,所以现在给大家介绍一个更简单的方法实现Web报表服务。

  使用.NET Framework 4.0或以上版本,就可以在现有项目技术上进行非常简单的修改,实现建立在Web服务基础上的Web报表应用了。接下来介绍一下通用的使用步骤。

1、.NET Framework 4.0下打开Visual Studio并创建一个新的ASP.NET Web Application的项目。

使用FastReport.Service.dll创建Web报表服务

2、添加引用库FastReport.dll,FastReport.Bars.dll,FastReport.Service.dll。

3、在站点根目录上创建一个名为ReportService.svc的文笔文件。

使用FastReport.Service.dll创建Web报表服务

4、在文本中增加以下代码:


<%@ ServiceHost Service="FastReport.Service.ReportService" %>
  
<%@ Assembly Name="FastReport.Service" %>


5、打开web.config,在<configuration>节中增加以下代码:

<appSettings>
 <!-- path to folder with reports -->
 <add key="FastReport.ReportsPath" value="C:\Program files\FastReports\FastReport.Net\Demos\WCF" />
 <!-- name of connection string for reports -->
 <add key="FastReport.ConnectionStringName" value="FastReportDemo" />
 <!-- Comma-separated list of available formats PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX.
 You can delete any or change order in this list. -->
 <add key="FastReport.Gear" value="PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX" />
 </appSettings>
 <connectionStrings>
 <add name="FastReportDemo" connectionString="XsdFile=;XmlFile=C:\Program Files\FastReports\FastReport.Net\Demos\Reports\nwind.xml"/>
 </connectionStrings>
 <system.serviceModel>
 <services>
 <service behaviorConfiguration="FastReportServiceBehavior" name="FastReport.Service.ReportService">
 <endpoint address="" binding="wsHttpBinding" contract="FastReport.Service.IFastReportService">
 <identity>
 <dns value="localhost" />
 </identity>
 </endpoint>
 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
 </service>
 </services>
 <behaviors>
 <serviceBehaviors>
 <behavior name="FastReportServiceBehavior">
 <serviceMetadata httpGetEnabled="True" />
 <serviceDebug includeExceptionDetailInFaults="True" />
 </behavior>
 </serviceBehaviors>
 </behaviors>
 <bindings>
 <basicHttpBinding>
 <binding messageEncoding="Mtom"
 closeTimeout="00:02:00" openTimeout="00:02:00"
 receiveTimeout="00:10:00" sendTimeout="00:02:00"
 maxReceivedMessageSize="67108864" maxBufferSize="65536"
 transferMode="Streamed">
 <security mode="None">
 <transport clientCredentialType="None" />
 </security>
 </binding>
 </basicHttpBinding>
 </bindings>
 </system.serviceModel>

注意:FastReport.ReportsPath是报表文件夹的路径,本示例中的路径是“\FastReport.Net\Demos\WCF”

FastReport.ConnectionStringName是连接字符串名称,应在<connectionStrings>中注册。

6、运行站点,来检查Web服务的可用性,出现以下页面便运行成功。

使用FastReport.Service.dll创建Web报表服务

注意:在服务器上部署项目时,FastReport.dll,FastReport.Bars.dll,FastReport.Service.dll要在/ bin文件夹中。

Web服务连接成功后,就在可以在Visual Studio中打开现有项目,点击ReportService选择Configure Service Reference设置就行了。

  最后把用到的FastReport .Net的Visual Studio 2013的下载放出来,VS2013真的很不错啊。

  FastReport .Net最新版本 下载>>

  Visual Studio 2013  下载>>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值