如何获得PDF格式的rdlc [英] HOW get rdlc in pdf
本文介绍了如何获得PDF格式的rdlc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用以下代码获得pdf格式的rdlc报告。
i want to get only pdf format of rdlc report using following code.
protected void ReportViewer2_Load(object sender, EventArgs e)
{
string exportOption = "Word";
string exportOption1 = "Excel";
RenderingExtension extension = ReportViewer2.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));
if (extension != null)
{
System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
fieldInfo.SetValue(extension, false);
}
RenderingExtension extension1 = ReportViewer2.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption1, StringComparison.CurrentCultureIgnoreCase));
if (extension1 != null)
{
System.Reflection.FieldInfo fieldInfo1 = extension1.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
fieldInfo1.SetValue(extension1, false);
}
}
问题是,当我使用PDF时,它会从下拉列表中隐藏PDF格式,但不能使用excel或单词??
plz指南
problem is that when i use "PDF" then its hide the PDF format from the dropdownlist ,but not working with excel or word??
plz guide
推荐答案
现在我将展示如何在运行时将RDLC报告保存为PDF格式。
我正在创建一个名为SAVEPDFData的方法,其中包含两个参数:
路径(位置)为字符串键入我们要保存该PDF文件的位置。
示例:C:\ MyFile \
另一个是ReportViewer,它是ReportViewer类的实例
我们将执行将报告转换为PDF的操作;但不仅仅是PDF,我们可以将文件保存为其他格式,例如Word或Excel。
Now I show how to save a RDLC report as a PDF at run time.
I am creating a method for that named "SAVEPDFData" with the two arguments:
Path (Location) as string type where we want to save that PDF file.
Example: C:\MyFile\
Another is ReportViewer that is the instance of the ReportViewer Class
On which we will perform the action to convert the report to a PDF; but not just PDF, we can save the file in another format, such as Word or Excel.
public void SavePDFData(ReportViewer viewer, string savePath)
{
byte[] Bytes = viewer.LocalReport.Render(format:"PDF",deviceInfo:"");
using (FileStream stream = new FileStream(savePath, FileMode.Create))
{
stream.Write(Bytes, 0, Bytes.Length);
}
}
这篇关于如何获得PDF格式的rdlc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文