阅读 163

报表生成器FastReport .Net如何使用FastReport.Service.dll?

FastReport .NET是适用于Windows Forms,ASP.NET,MVC和.NET Core的全功能报表解决方案。它可以在Microsoft Visual Studio 2005-2019中使用。支持.Net Framework 2.0-4.x,.NET Core 3.0及以上版本。

在FastReport .NET 2021.1的新版本中,我们实现了对.NET 5的支持。添加了新条形码-Deutsce Post Leitcode。将RTF转换为报告对象的算法已得到显着改进。并且还添加了用于转换数字的新功能。欢迎下载体验。【慧都网快速获取最新试用版】

使用FastReport .Net提供的库FastReport.Service.dll(WCF服务库)实现网络服务有一个简单的方法。

我们的例子是基于创建一个具有web服务功能的简单web应用程序,但您可以基于.NET Framework 4.0或更高版本修改您现有的项目。

运行Visual Studio并在.NET Framework 4.0下创建一个新的ASP.NET Web应用程序项目。

添加对库FastReport.dll、FastReport.Bars.dll、FastReport.Service.dll的引用 在站点根目录下创建一个名称为ReportService.svc的新文本文件。

在文件中添加以下几行内容。

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

打开web.config,在<配置>部分添加这段代码。

<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.Net\Demos\WCF"。

键 "FastReport.ConnectionStringName "应该包含连接字符串名称。这一行应该在<connectionStrings>部分注册。

让我们运行我们的网站,通过访问文件ReportService.svc来检查Web服务的可用性。

当你在服务器上部署项目时,一定要检查文件FastReport.dll,FastReport.Bars.dll、FastReport.Service.dll是否在文件夹\bin中。

客户端程序的例子可以在文件夹 \FastReport.Net/Demos/C#/WCFClient 和 \FastReport.Net/Demos/C#/WCFWebClient 中找到。在Visual Studio中打开每个项目,右击ReportService,在弹出的对话框中选择配置服务参考。


在配置窗口中指定现有Web服务的地址。

如果您对FastReport感兴趣,可以在慧都网免费下载最新试用版,加入FastReport QQ交流群:783996712

©著作权归作者所有:来自51CTO博客作者wx5ff69c7357962的原创作品,如需转载,请注明出处,否则将追究法律责任


文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐