rdlc水晶报表在wpf里的使用
1引用程序集
Microsoft.ReportViewer.WinForms
2 xaml 命名空间
xmlns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
3 xaml 里用windowsFormsHost 来装报表控件
<WindowsFormsHost Margin="135,75,0,0" Panel.ZIndex="-1" Height="auto">
<rv:ReportViewer x:Name="reportViewer" />
</WindowsFormsHost>
3.初始化控件参数
this.reportViewer.Messages = new Health.Client.Base.ReportViewerMessagesZhcn();
public class ReportViewerMessagesZhcn : IReportViewerMessages
{
public string BackButtonToolTip { get { return "后退"; } } public string BackMenuItemText { get { return "后退"; } } public string ChangeCredentialsText { get { return "更改"; } } public string CurrentPageTextBoxToolTip { get { return "当前页"; } } public string DocumentMapButtonToolTip { get { return "文档视图"; } } public string DocumentMapMenuItemText { get { return "文档视图"; } } public string ExportButtonToolTip { get { return "导出"; } } public string ExportMenuItemText { get { return "选择格式"; } } public string FalseValueText { get { return "不正确的值"; } } public string FindButtonText { get { return "查找"; } } public string FindButtonToolTip { get { return "查找"; } } public string FindNextButtonText { get { return "下一个"; } } public string FindNextButtonToolTip { get { return "下一个"; } } public string FirstPageButtonToolTip { get { return "首页"; } } public string LastPageButtonToolTip { get { return "最后一页"; } } public string NextPageButtonToolTip { get { return "下一页"; } } public string NoMoreMatches { get { return "无匹配项"; } } public string NullCheckBoxText { get { return "空值"; } } public string NullCheckBoxToolTip { get { return "空值"; } } public string NullValueText { get { return "空值"; } } public string PageOf { get { return "页"; } } public string PageSetupButtonToolTip { get { return "页面设置"; } } public string PageSetupMenuItemText { get { return "页面设置"; } } public string ParameterAreaButtonToolTip { get { return "参数设置区"; } } public string PasswordPrompt { get { return "请输入密码:"; } } public string PreviousPageButtonToolTip { get { return "前一页"; } } public string PrintButtonToolTip { get { return "打印"; } } public string PrintLayoutButtonToolTip { get { return "打印"; } } public string PrintLayoutMenuItemText { get { return "打印"; } } public string PrintMenuItemText { get { return "打印"; } } public string ProgressText { get { return "正在生成报表......"; } } public string RefreshButtonToolTip { get { return "刷新"; } } public string RefreshMenuItemText { get { return "刷新"; } } public string SearchTextBoxToolTip { get { return "查找"; } } public string SelectAll { get { return "全选"; } } public string SelectAValue { get { return "SelectAValue"; } } public string StopButtonToolTip { get { return "停止"; } } public string StopMenuItemText { get { return "停止"; } } public string TextNotFound { get { return "未找到"; } } public string TotalPagesToolTip { get { return "总页数"; } } public string TrueValueText { get { return "正确值"; } } public string UserNamePrompt { get { return "用户名"; } } public string ViewReportButtonText { get { return "显示报表"; } } public string ViewReportButtonToolTip { get { return "显示报表"; } } public string ZoomControlToolTip { get { return "缩放"; } } public string ZoomMenuItemText { get { return "缩放"; } } public string ZoomToPageWidth { get { return "页宽"; } } public string ZoomToWholePage { get { return "整页"; } }
}
4 .加载视图,设置视图RDLC的方法
private void ShowReportViewer(int index, Microsoft.Reporting.WinForms.ReportDataSource dataSourse, List<Microsoft.Reporting.WinForms.ReportParameter> reportParameters, System.Collections.IEnumerable detailDataSource)
{
ReportViewer reportViewer = SelectReportViewer(index);
//索引超出范围
if (reportViewer == null) return;
if (dataSourse != null)
{
reportViewer.LocalReport.ReportPath = GetReportFilePath(dataSourse.Name);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(dataSourse);
}
else
{
reportViewer.LocalReport.ReportPath = GetReportFilePath("ChargeFeezyAmountMain");
reportViewer.LocalReport.DataSources.Clear();
} if (reportParameters != null)
{
reportViewer.LocalReport.SetParameters(reportParameters);
} if (detailDataSource != null)
{
_subDataSource = detailDataSource as List<ReportDataSource>;
reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
}
//if (dataSourse.Name == "CancelArrears")
//{
// var pageSettings = reportViewer.GetPageSettings(); // pageSettings.Landscape = false;
// reportViewer.SetPageSettings(pageSettings);
//}
//else if (dataSourse.Name == "CarrearagePat" || dataSourse.Name == "RecoveryArrears")
//{
// var pageSettings = reportViewer.GetPageSettings(); // pageSettings.Landscape = true;
// reportViewer.SetPageSettings(pageSettings);
//}
reportViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
reportViewer.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
reportViewer.ZoomPercent = ;
reportViewer.RefreshReport();
}
private void ShowReportViewer1(int index, List<Microsoft.Reporting.WinForms.ReportDataSource> dataSourse, List<Microsoft.Reporting.WinForms.ReportParameter> reportParameters, System.Collections.IEnumerable detailDataSource)
{
ReportViewer reportViewer = SelectReportViewer(index);
//索引超出范围
if (reportViewer == null) return;
if (dataSourse != null)
{
reportViewer.LocalReport.ReportPath = Health.Reports.ReportHelper.GetReportFilePath(dataSourse[].Name);
reportViewer.LocalReport.DataSources.Clear();
foreach (var data in dataSourse)
{
reportViewer.LocalReport.DataSources.Add(data);
}
}
else
{
reportViewer.LocalReport.ReportPath = Health.Reports.ReportHelper.GetReportFilePath("ChargeFeezyAmountMain");
reportViewer.LocalReport.DataSources.Clear();
} if (reportParameters != null)
{
reportViewer.LocalReport.SetParameters(reportParameters);
}
if (detailDataSource != null)
{
_subDataSource = detailDataSource as List<ReportDataSource>;
reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
}
reportViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
reportViewer.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
reportViewer.ZoomPercent = ;
reportViewer.RefreshReport();
}
private ReportViewer SelectReportViewer(int index, bool isReset = true)
{
if (isReset) reportViewer.Reset();
return reportViewer;
}
private void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
foreach (var item in _subDataSource)
{
e.DataSources.Add(item);
}
}
public static string GetReportFilePath(string reportFileName)
{ string filePath= @"Reports\" + reportFileName + ".rdlc";
filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath);
if(!System.IO.File.Exists(filePath))
{
return "";
} return filePath;
}
调用
rdlc水晶报表在wpf里的使用的更多相关文章
- 水晶报表,快速报表,rdlc报表
感觉自己脑子里只剩下报表了,o(╥﹏╥)o.因为最近新换了公司,业务上有需要报表打印,水晶报表,快速报表,rdlc报表这三种以后可能都会用到.所以在没了解好业务流程,熟悉代码之前,就是看看这三种报表怎 ...
- WPF SAP水晶报表例子和打包Setup
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=" ...
- RDLC报表 在WinForm里运行出现 未能加载文件或程序集 Microsoft.ReportViewer.WinForms, Version=11.0.0.0 System.IO.FileNotFoundException
原文:RDLC报表 在WinForm里运行出现 未能加载文件或程序集microsoft.reportviewer.winforms 推荐以下方案二 做一下记录顺便帮助一下遇到问题的朋友. 做RDLC报 ...
- 水晶报表在vs2010 WPF环境下的尝试
原文:水晶报表在vs2010 WPF环境下的尝试 由于VS2010没有集成水晶报表组件,尝试前必须先安装 水晶报表 for VS2010,若机器未安装的可点击这里>>>下载安装 新建 ...
- 水晶报表和rdlc报表传入参数筛选
在使用报表向客户展示结果数据时,实时的在报表中显示某些特定的数据是必需的,如:显示的部门.打印的日期等.本文只简单的演示向报表内传入一个字符值. 以下是设计好报表之后传入参数的具体操作 一.首先是水晶 ...
- 水晶报表连接Oracle做数据报表笔记
首先,新建一个水晶报表的文件,这个时候要给这个报表文件绑定一个oracle数据源, 选择右侧菜单的这个东西,选择“数据库专家”,打开之后是这么一个界面: 选择建立新连接: 这个地方最关键,也是我为什么 ...
- rpt水晶报表制作过程
原文:rpt水晶报表制作过程 最近公司安排一个以前的项目,里面需要用到水晶报表,由于原来做这个项目的同事离职,所在公司的同事报表做成了rdlc类型的,而这类报表在加载的时候很难动态的从数据库加载数据, ...
- 只用最适合的! 全面对比主流 .NET 报表控件:水晶报表、FastReport、ActiveReports 和 Stimulsoft
前言 随着 .NET 平台的出现,报表相关的开发控件随之出现,目前已经有若干成熟的产品可供开发人员使用,本文旨在通过从不同维度对比目前最流行的4款 .NET报表控件,给所有报表开发人员在做产品选型时一 ...
- C#水晶报表,窗体不显示,闪退
一.问题说明 由于VS2008以后水晶报表不在集成,要用的话需要单独下载. 这里注意如果是用在C#窗体程序里的话一定要下载exe文件,安装msi文件的话VS工具栏里找不到水晶报表控件的.如果你的是64 ...
随机推荐
- [ExtJS5学习笔记]第九节 Extjs5的mvc与mvvm框架结构简单介绍
本文地址:http://blog.csdn.net/sushengmiyan/article/details/38537431 本文作者:sushengmiyan ------------------ ...
- 编译器是C写的,包括一点C++,editor和debugger是C++写的(最早的16位编译器是纯汇编写的)
16bit compiler was written in pure assembler. The current compiler is written in C. It was derived f ...
- Oracle数据库零散知识09 -- DBLink的创建(转)
通过创建database link实现Oracle跨数据库查询的方法 在Oracle本地数据库端执行赋权dbuser帐号 SQL> grant create database link to d ...
- UUID不失精度,长度改进
在使用到uuid的时候,往往头疼于它的长度(如1bfe50d8-544e-4e8a-95b8-199ceff15268),于是乎就有了改写uuid的各种方法 1.去除"-"的uui ...
- freemarker中间split字符串切割
freemarker中间split字符串切割 1.简易说明 split切割:用来依据另外一个字符串的出现将原字符串切割成字符串序列 2.举例说明 <#--freemarker中的split字符串 ...
- 微信小程序开发demo-地图定位
要求要完成的功能: 1.要完成的要点是城市定位. 2.就是切换城市. 首页我们先参照微信小程序开放的官方文档找到: 在这里我们可以找到”当前位置经纬度“ getLocation: function ( ...
- Android菜鸟的成长笔记(22)——Android进程间传递复杂数据(AIDL)
在上一篇中介绍了Andorid中的进程间的通信方式AIDL,本篇文章将介绍传递复杂数据的AIDL Service 下面通过一个示例说明: 本例子中用到了两个自定义类型:Person与Pet, 其中Pe ...
- JSP和Servlet学习笔记1 - 访问配置
1. 访问 WebContent 目录下的 JSP 文件 在 WebContent 目录下的文件可以直接在浏览器中访问.新建一个 test.jsp 文件 <%@ page language=&q ...
- CUDA页锁定内存(Pinned Memory)
对CUDA架构而言,主机端的内存被分为两种,一种是可分页内存(pageable memroy)和页锁定内存(page-lock或 pinned).可分页内存是由操作系统API malloc()在主机上 ...
- QT之QSignalMapper(可以理解为转发器,多个按钮绑定到一个Edit上,且能分辨。每个单独连接的话,反而麻烦)
QT之QSignalMapper QT之QSignalMapper 简述 效果图 上代码 相关知识点文章 结尾 简述 QSignalMapper我们可以理解为转发器,此话怎讲呢?比如,按钮点击的响应槽 ...