求大神怎样教我用Active report9怎样导出pdf
:求大神怎样教我用Active report9怎样导出pdf 您好,AR的报表分为RDL,页面报表和区域报表。
以应用最广泛的RDL报表为例,可以使用以下代码实现导出pdf
protected void btnPdf_Click(object sender, EventArgs e)
{
// Provide the page report you want to render.
string report = "rptInvoice";
GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("~/Reports/" + report + ".rdlx")));
_reportDef.Report.DataSources.DataSourceReference = "";
_reportDef.Report.DataSources.ConnectionProperties.DataProvider = "OLEDB";
_reportDef.Report.DataSources.ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("~/Data/NWind_CHS.mdb"));
GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);
// Create an output directory
System.IO.MemoryStream ms = new System.IO.MemoryStream();
// 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.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
_reportRuntime.Render(pdfRenderingExtension, outputProvider, pdfSetting);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline;filename=客户订单.pdf");
outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
Response.BinaryWrite(ms.ToArray());
Response.End();
}
希望能够帮助到您。 您好,
距离这个问题的最后回复已经过去了一段时间,不知道这个问题您是否已经解决?
如果没有解决,欢迎跟贴接续讨论,如果已经解决请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
http://gcdn.gcpowertools.com.cn/attachment.aspx?attachmentid=10062 回复 2楼frank.zhang的帖子
你好,我想问下我的是dataset数据集,怎么样赋值到报表文件上然后导出电子表格,或者是文档,或者是pdf
而不是例子里面这样的赋值。
_reportDef.Report.DataSources.DataSourceReference = "";
_reportDef.Report.DataSources.ConnectionProperties.DataProvider = "OLEDB";
_reportDef.Report.DataSources.ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("~/Data/NWind_CHS.mdb")); 回复 4楼jishaojia的帖子
您好,
这个问题我们在http://gcdn.gcpowertools.com.cn/showtopic-19747.html
中继续讨论
页:
[1]