找回密码
 立即注册

QQ登录

只需一步,快速开始

bisslot
论坛元老   /  发表于:2015-3-25 16:26  /   查看:7232  /  回复:11
我的问题如下:

(1) 目前使用的是AR9.0 专业版控件, 项目类型为WINFORM , 创建的是RDL报表类型,我想在运行时引用数据源 ,可是AR9的 Viewer 控件LocateDataSource 不触发,请问是什么原因呢?
我的代码如下:

  1. private void c1Button1_Click(object sender, EventArgs e)
  2.         {
  3.             string fileName = @"..\..\RdlReport1.rdlx";
  4.             PageReport pReport1 = new PageReport(new System.IO.FileInfo(fileName));
  5.             PageDocument pDocument1 = new PageDocument(pReport1);
  6.             viewer1.LoadDocument(pDocument1);
  7.         }

  8.         private DataTable GetDataSource()
  9.         {
  10.             DataTable dt = new DataTable();
  11.             dt.Columns.Add("产品ID");      dt.Columns.Add("产品名称");    dt.Columns.Add("库存量");     dt.Columns.Add("单价");

  12.             dt.Rows.Add("0001", "香蕉", 100.00, 4.20);       dt.Rows.Add("0002", "西瓜", 50.00, 6.50);
  13.             dt.Rows.Add("0003", "葡萄", 60.00, 2.10);        dt.Rows.Add("0004", "火龙果", 30.00, 15.20);
  14.             return dt;
  15.         }

  16.         private void viewer1_LocateDataSource(object sender, LocateDataSourceEventArgs args)
  17.         {
  18.             MessageBox.Show("LocateDataSource Event!");
  19.         }
复制代码


(2) 我如何在 WinForm 表单中的Viewer 控件工具栏中出现导出功能图标按钮呢?
操作系统: Windows 7 简体中文 64位旗舰版 , 开发工具: Visual Studio 2010 简体中文专业版, ComponentOne  Universal 用户

11 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-3-25 17:09:00
沙发
您好。
第一个问题:
需要增加以下代码
  1. runtime.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(runtime_LocateDataSource);
复制代码


设置数据源为DataSet



可以参下以下文章
http://blog.gcpowertools.com.cn/ ... Source_RunTime.aspx

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

评分

参与人数 1满意度 +5 收起 理由
bisslot + 5 谢谢

查看全部评分

回复 使用道具 举报
bisslot
论坛元老   /  发表于:2015-3-25 17:28:00
板凳
关于第2个问题,如何在 Viewer 报表浏览器的工具栏中出现 导出功能的图标按钮呢? 比如可以导出 Excel 或 Word 或 PDF ?
操作系统: Windows 7 简体中文 64位旗舰版 , 开发工具: Visual Studio 2010 简体中文专业版, ComponentOne  Universal 用户
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-3-25 17:33:00
地板
您好,
第二个问题,增加以下代码
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             viewer1.Print(true, true, true);
  4.         }
复制代码
回复 使用道具 举报
bisslot
论坛元老   /  发表于:2015-3-25 17:58:00
5#
我的意思是如何在 Viewer 控件的工具栏中增加导出功能按钮? 默认没有
参加如下图所示


刚刚接触 ActiveReport ,麻烦您了!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
操作系统: Windows 7 简体中文 64位旗舰版 , 开发工具: Visual Studio 2010 简体中文专业版, ComponentOne  Universal 用户
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-3-25 18:09:00
6#
您好,
请问您想导出的是什么格式的文档?我们支持excel,word等。
回复 使用道具 举报
bisslot
论坛元老   /  发表于:2015-3-25 18:12:00
7#
你好,我记得在产品演示的时候,我视乎看到过在报表预览工具栏中有导出的下拉按钮可以xls , pdf , 或word 等其它格式吧
操作系统: Windows 7 简体中文 64位旗舰版 , 开发工具: Visual Studio 2010 简体中文专业版, ComponentOne  Universal 用户
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-3-25 18:14:00
8#
您好,
以PDF为例子
  1.             // Provide the page report you want to render.
  2.             GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new
  3.             System.IO.FileInfo(@"..\..\RdlReport1.rdlx"));
  4.             GrapeCity.ActiveReports.Document.PageDocument reportDocument = new
  5.             GrapeCity.ActiveReports.Document.PageDocument(report);
  6.             // Create a output directory
  7.             System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
  8.             outputDirectory.Create();
  9.             // Provide settings for your rendering output.
  10.             GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new
  11.             GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
  12.             GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = pdfSetting;
  13.             //Set the rendering extension and render the report.
  14.             GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension =
  15.             new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
  16.             GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new
  17.             GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory,
  18.             System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
  19.             reportDocument.Render(pdfRenderingExtension, outputProvider, pdfSetting);
复制代码


导出后的目录C:\MyPDF
回复 使用道具 举报
bisslot
论坛元老   /  发表于:2015-3-25 18:30:00
9#
这个问题比较让我困惑,我希望能让用户在预览工具栏中具有导出的功能。
操作系统: Windows 7 简体中文 64位旗舰版 , 开发工具: Visual Studio 2010 简体中文专业版, ComponentOne  Universal 用户
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-3-26 09:33:00
10#
您好,
各个平台的Viewer都提供了自定义的能力,我们有相应的示例,可以根据自己的需要来扩展。
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部