AR9支持导出一个数据源是一个DataSet的Excel或者Pdf
AR9支持导出一个数据源是一个DataSet的Excel或者Pdf吗我的这个DataSet是个从数据库中查出来的
我想导出时候将这个dataset导出来,大神能实现吗? 您好,
我对您的问题理解为,将一个数据源例如DataSet,不经过展示,直接导出为excel或者pdf吗?
如果理解的不正确,希望补充。 对!!按导出按钮不展示直接提示下载 您好,
在AR中,导出是通过PageReport执行的。
可以在按钮中,直接创建一个PageReport,然后导出。不进行显示。
protected void Button3_Click(object sender, EventArgs e)
{
// Provide the page report you want to render.
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.Excel.Page.ExcelRenderingExtensionSettings
excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;
//excelSetting.MultiSheet = false;
GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;
//Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension
excelRenderingExtension = new
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
_reportRuntime.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "inline;filename=MyExport.xls");
outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
Response.BinaryWrite(ms.ToArray());
Response.End();
}
大神把pdf的demo也发一下呗谢谢大神 感谢大神 回复 5楼Exep的帖子
好的,
多问一句,你和楼主是一家公司的吗? 大神其实你猜对了我们都在研究这东西 we are team 您好,
这个问题重复帖,我们在
http://gcdn.gcpowertools.com.cn/showtopic-18107.html继续讨论。 回复 4楼frank.zhang的帖子
大神啊。贴主应该是想表达说不要类似
_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"));
这样赋值,我们想的是dataset的方法来赋值到里面去导出也和画的报表风格一致。
页:
[1]
2