C# 将定义的名称放入asp.net c中的reportviewer PDF中#
我有一段代码,它的作用是生成一个 PDF或EXCEL。 我如何定义货币,以可视化或下载给我这个名字。 例子 EXCEL.EXCEL或PDF.PDF 我正在寻找定义固定名称示例的方法 rodo.pdf或rodo.excelC# 将定义的名称放入asp.net c中的reportviewer PDF中#,c#,asp.net,reportviewer,C#,Asp.net,Reportviewer,我有一段代码,它的作用是生成一个 PDF或EXCEL。 我如何定义货币,以可视化或下载给我这个名字。 例子 EXCEL.EXCEL或PDF.PDF 我正在寻找定义固定名称示例的方法 rodo.pdf或rodo.excel public ActionResult打印(参数general param,字符串id,FormCollection tiporeport) { string Format=“pdf”; //字符串格式=“excel”; LocalReport lr=新的LocalReport
public ActionResult打印(参数general param,字符串id,FormCollection tiporeport)
{
string Format=“pdf”;
//字符串格式=“excel”;
LocalReport lr=新的LocalReport();
字符串path=System.IO.path.Combine(Server.MapPath(“~/Reportes”),“Libro.rdlc”);
if(System.IO.File.Exists(path))
{
lr.ReportPath=path;
}
其他的
{
返回视图(“索引”);
}
ReportDataSource rd=新的ReportDataSource(“DSLibro”,LibroVenta(2018年4月)。表[0]);//这里返回我的查询以及我发送的2018年4月和2018年的仪表
lr.数据源添加(rd);
字符串报告类型=格式;
弦雷型;
字符串编码;
字符串文件名扩展名;
字符串设备信息=
"" +
“”+格式+“”+
“11英寸”+
“8.5英寸”+
“0787402in”+
“0787402in”+
“0787402in”+
“0787402in”+
"";
警告[]警告;
字符串[]流;
字节[]渲染字节;
renderedBytes=lr.Render(
报告类型,
deviceInfo,
除雷型外,
输出编码,
输出文件名扩展名,
流出的溪流,
发出警告);
返回文件(renderdbytes,mineType);
}
试着按照这些思路来做。文件名将是somepdf.pdf
var cd = new System.Net.Mime.ContentDisposition
{
FileName = "somepdf.pdf",
Inline = true
};
Response.Headers.Add("Content-Disposition", cd.ToString());
return File(bytes, "application/pdf");
你好,你好???@RodrigoRodriguez你似乎在哪里错过了它。在
返回文件(renderdbytes,mineType)之前,将内容配置添加到响应头中代码>
var cd = new System.Net.Mime.ContentDisposition
{
FileName = "somepdf.pdf",
Inline = true
};
Response.Headers.Add("Content-Disposition", cd.ToString());
return File(bytes, "application/pdf");