关于运行时数据源的使用问题
我的问题如下:(1) 目前使用的是AR9.0 专业版控件, 项目类型为WINFORM , 创建的是RDL报表类型,我想在运行时引用数据源 ,可是AR9的 Viewer 控件LocateDataSource 不触发,请问是什么原因呢?
我的代码如下:
private void c1Button1_Click(object sender, EventArgs e)
{
string fileName = @"..\..\RdlReport1.rdlx";
PageReport pReport1 = new PageReport(new System.IO.FileInfo(fileName));
PageDocument pDocument1 = new PageDocument(pReport1);
viewer1.LoadDocument(pDocument1);
}
private DataTable GetDataSource()
{
DataTable dt = new DataTable();
dt.Columns.Add("产品ID"); dt.Columns.Add("产品名称"); dt.Columns.Add("库存量"); dt.Columns.Add("单价");
dt.Rows.Add("0001", "香蕉", 100.00, 4.20); dt.Rows.Add("0002", "西瓜", 50.00, 6.50);
dt.Rows.Add("0003", "葡萄", 60.00, 2.10); dt.Rows.Add("0004", "火龙果", 30.00, 15.20);
return dt;
}
private void viewer1_LocateDataSource(object sender, LocateDataSourceEventArgs args)
{
MessageBox.Show("LocateDataSource Event!");
}
(2) 我如何在 WinForm 表单中的Viewer 控件工具栏中出现导出功能图标按钮呢? 您好。
第一个问题:
需要增加以下代码
runtime.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(runtime_LocateDataSource);
设置数据源为DataSet
可以参下以下文章
http://blog.gcpowertools.com.cn/post/2014/08/01/ActiveReports_DataSource_RunTime.aspx 关于第2个问题,如何在 Viewer 报表浏览器的工具栏中出现 导出功能的图标按钮呢? 比如可以导出 Excel 或 Word 或 PDF ? 您好,
第二个问题,增加以下代码
private void button1_Click(object sender, EventArgs e)
{
viewer1.Print(true, true, true);
} 我的意思是如何在 Viewer 控件的工具栏中增加导出功能按钮? 默认没有
参加如下图所示
刚刚接触 ActiveReport ,麻烦您了! 您好,
请问您想导出的是什么格式的文档?我们支持excel,word等。 你好,我记得在产品演示的时候,我视乎看到过在报表预览工具栏中有导出的下拉按钮可以xls , pdf , 或word 等其它格式吧 您好,
以PDF为例子
// Provide the page report you want to render.
GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new
System.IO.FileInfo(@"..\..\RdlReport1.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument reportDocument = new
GrapeCity.ActiveReports.Document.PageDocument(report);
// Create a output directory
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
outputDirectory.Create();
// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new
GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = pdfSetting;
//Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension =
new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory,
System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
reportDocument.Render(pdfRenderingExtension, outputProvider, pdfSetting);
导出后的目录C:\MyPDF 这个问题比较让我困惑,我希望能让用户在预览工具栏中具有导出的功能。 您好,
各个平台的Viewer都提供了自定义的能力,我们有相应的示例,可以根据自己的需要来扩展。
页:
[1]
2