如何从resx文件获取报告? [英] How to have a report from resx file?

查看:96
本文介绍了如何从resx文件获取报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2010有一个小项目。在生成rdlc报告时,我希望从程序集或resx文件中访问它。是否可能?



我的目的是从项目本身加载报告,因为它将嵌入EXE。因此原始的rdlc不需要与最终用户系统保持一致。



感谢帮助



来自下面的代码ImageResources是Resx文件名。

Report_DeliveryNote是报告名称。我尝试了以下方式...需要改变





Hi, I have a small project in VS2010. While generating the rdlc report I wish to access it from assembly or resx file. Is it possible?

My intention is to load the report from my project itself, because it will be embeded with EXE. Therefore the original rdlc is not required to keep with enduser systems.

Thanks For The Helps

From the below code ImageResources is the Resx file name.
Report_DeliveryNote is report name. I tried like the below manner...need to alter


Reflection.Assembly TxAssembly = Reflection.Assembly.GetExecutingAssembly();
String TxResName = TxAssembly.GetName().Name + ".ImageResources";
ResourceManager Tx_ResourceManager = (new Resources.ResourceManager(TxResName,TxAssembly));
Microsoft.Reporting.WinForms.Report MyRept =(safe_cast<Microsoft.Reporting.WinForms.Report>(Tx_ResourceManager.GetObject("Report_DeliveryNote")));

reportViewer1.LocalReport.LoadReportDefinition(MyRept);





再次感谢



Thanks Again

推荐答案

我希望这会对你有所帮助:



I hope this will help you:

Reflection.Assembly TxAssembly = Reflection.Assembly.GetExecutingAssembly();
// Full path to your report files with folders: Reports\MyReport.rdlc = Reports.MyReport.rdlc
Stream stream = TxAssembly.GetManifestResourceStream("Reports.MyReport.rdlc");
reportViewer1.LocalReport.LoadReportDefinition(stream);











or

reportViewer1.LocalReport.ReportEmbeddedResource = "Reports.MyReport.rdlc";





重要的是EXE文件中报告文件的完整路径。



Important is full path to your report file within EXE file.


这篇关于如何从resx文件获取报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆