Tôi đang cố gắng in tệp RDLC trực tiếp mà không hiển thị Trình xem Báo cáo Microsoft, tôi đã theo dõi MSDN's example nhưng bây giờ, mỗi lần tôi gọi phương thức "Render" Ví dụ của tôi lớp LocalReport nó ném "Một hoặc nhiều tham số cần thiết để chạy báo cáo chưa được chỉ định." ngoại lệ.Một hoặc nhiều tham số cần thiết để chạy báo cáo chưa được chỉ định
Bất kỳ ai có thể cho tôi biết tham số nào là bắt buộc mà tôi đã bỏ lỡ? hoặc làm cách nào tôi có thể tìm thêm chi tiết về ngoại lệ này?
LocalReport report = new LocalReport();
report.ReportPath = System.Windows.Forms.Application.StartupPath + "\\" + rdlcFileName;
report.EnableExternalImages = true;
ReportParameter[] reportParams = new ReportParameter[]
{
new ReportParameter("LogoAddress", settings.LogoFileName),
new ReportParameter("FooterValue", settings.InvoicesFooter)
};
report.SetParameters(reportParams);
report.DataSources.Add(new ReportDataSource("Invoice", new PrintableInvoice[] { invoice }));
report.DataSources.Add(new ReportDataSource("InvoiceItem", invoiceItems));
Warning[] warnings;
try
{
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.25in</MarginTop>" +
" <MarginLeft>0.25in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>0.25in</MarginBottom>" +
"</DeviceInfo>";
m_streams = new List<Stream>();
report.Render("Image", deviceInfo, _CreateStream, out warnings);
foreach(Stream stream in m_streams)
stream.Position = 0;
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
và _CreateStream là:
private Stream _CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new FileStream(name + "." + fileNameExtension, FileMode.Create);
m_streams.Add(stream);
return stream;
}
câu trả lời được tìm thấy tại: http://social.msdn.microsoft.com/Forums/zh/vsreportcontrols/thread/7cce3c91-f876-417a-81cc-10e10dde0e40 – MilkyWayJoe