【发布时间】:2015-10-01 14:53:07
【问题描述】:
也许有人问过这个问题,如果是,请随时为我指出正确的方向。
我有一份关于 SSRS 的报告,我的数据集/数据源当然在那里。数据集是一个动态查询。
这个想法是通过 Excel 导出报告的结果。
我的 Aspx 中有一个 Web 服务器控件 ReportViewer。有谁知道是否有导出到 excel 的方法以及如何在我的代码中对其进行编码。
如果您需要更多信息,请告诉我,我会发布。
编辑: 检查信息和其他链接我做了以下方法。
private void CreateEXCEL(Dictionary<string, string> parametros, string nombreReporte)
{
// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
List<ReportParameter> parameters = new List<ReportParameter>();
foreach (var d in parametros)
{
parameters.Add(new ReportParameter(d.Key, d.Value));
}
// Setup the report viewer object and get the array of bytes
MyReportViewer.ProcessingMode = ProcessingMode.Remote;
MyReportViewer.ServerReport.ReportPath = nombreReporte;
MyReportViewer.ServerReport.SetParameters(parameters);
byte[] bytes = MyReportViewer.ServerReport.Render("EXCEL", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + nombreReporte + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download
}
但是当我执行我的网络应用程序并调用此方法时,我有以下错误:
服务器犯了协议违规Section=ResponseStatusLine
有人遇到过这样的问题吗?
【问题讨论】:
-
这看起来像你要找的东西:stackoverflow.com/questions/12241736/…
标签: c# asp.net reporting-services ssrs-2008