如何解决在.cs类而非aspx.cs中检索RDLC报告字节[]
我有一个aspx.cs页面
其中有一个RDLC报告,因此我从该报告中检索字节[]并将其转换为base 64,然后将其返回到前端。
现在,我想在.cs类中创建一个方法,可以在其中指向此报告并检索相同的字节[]。 可以这样做吗?
我的页面aspx.cs
protected void Page_Init(object sender,EventArgs e)
{
SqlDataSource1.SelectParameters["param1"].DefaultValue = "1";
SqlDataSource1.SelectParameters["param2"].DefaultValue = "100";
ReportDataSource datasource1 = new ReportDataSource("ds_ops",SqlDataSource1);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource1);
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
byte[] bytes = ReportViewer1.LocalReport.Render("PDF",null,out mimeType,out encoding,out extension,out streamIds,out warnings);
string Base64 = Convert.ToBase64String(bytes);
Response.Clear();
Response.ContentType = "application/json; charset=utf-8";
Response.Write("data:application/pdf;base64," + Base64);
Response.End();
}
我正在尝试访问上述报告并检索字节[] em .cs
的方法 public void getRelatorio()
{
ReportViewer report = new ReportViewer();
SqlDataSource sqlDataSource = new SqlDataSource();
sqlDataSource.SelectParameters["param1"].DefaultValue = "";
sqlDataSource.SelectParameters["param2"].DefaultValue = "";
ReportDataSource datasource1 = new ReportDataSource("ds_ops",sqlDataSource);
report.LocalReport.DataSources.Clear();
report.LocalReport.DataSources.Add(datasource1);
/**/
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。