使用 ReportViewer 对象打印Microsoft report(.rdlc)
本文关键字:rdlc report Microsoft ReportViewer 对象 打印 使用 | 更新日期: 2023-09-27 18:35:29
我需要知道如何使用ReportViewer对象打印Microsoft报表(.rdlc) 没有来自Consol应用程序的WinFrom? 这种方式正确吗?
命名空间 ReportProntTset { 公开课程序 {
public static ReportViewer rp = new Microsoft.Reporting.WinForms.ReportViewer();
static void Main(string[] args) {
Start:
Console.WriteLine("'nTo print picture one enter 0.'nFor second one enter any number.'n");
int a = 0;
string report = "";
try {
a = Convert.ToInt32(Console.ReadLine());
if (a == 0) {
report = @"..'One.rdlc";
}
else {
report = @"..'Two.rdlc";
}
InitializeComponent(report);
rp.Refresh();
string ex = Print();
if (ex != "") {
Console.WriteLine(ex);
goto Start;
}
}
catch (Exception) {
Console.WriteLine("Please Insert Right Charcter");
goto Start;
}
}
public static string Print() {
string exa = "";
try {
rp.PrintDialog();
rp.Clear();
rp.LocalReport.ReleaseSandboxAppDomain();
}
catch (Exception ex) {
exa = ex.Message;
}
return exa;
}
private static void InitializeComponent(string report) {
Form fr = new Form();
PrintDialog prDial = new System.Windows.Forms.PrintDialog();
PrintDocument prDoc = new System.Drawing.Printing.PrintDocument();
fr.SuspendLayout();
//
//pr
//enter code here
rp.LocalReport.ReportEmbeddedResource = report;
rp.Location = new System.Drawing.Point(0, 0);
rp.Name = "ViewReport";
rp.Size = new System.Drawing.Size(0, 0);
rp.TabIndex = 0;
//
// prDial
// `enter code here`
prDial.UseEXDialog = true;
//
// fr
//
fr.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
fr.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
fr.ClientSize = new System.Drawing.Size(0, 0);
fr.Controls.Add(rp);
fr.Name = "ReportForm";
fr.Text = "ImagePrint";
fr.ResumeLayout(false);enter code here
}
}
}
你能帮我解决这个小问题吗?我相信没有什么可以添加或更改:)
获取呈现的内容,然后您可以执行任何操作:
var content = reportViewer.LocalReport.Render("PDF")