,水晶報表也上到今天爲止,SQL Server 2012的通過對象填充水晶報表數據源和ExportToStream
我想通過一個視圖模型類填充水晶報表數據源並將其導出到PDF
ReportDocument rptH = new ReportDocument();
rptH.FileName = Server.MapPath("~/reports/InvoiceReportsSample1.rpt");
var showInvoices =
(from ids in context.Invoices
where ids.InvoiceNumber == "01-04-2017-1"
select new Invoice_Report_ViewModel()
{
Invoiceid = ids.Invoiceid,
InvoiceNumber = ids.InvoiceNumber,
CustomerCompanyName = ids.CustomerCompanyName,
FirstBlankSpaceForPanel1 = ids.FirstBlankSpaceForPanel1,
MainDiscount = ids.MainDiscount,
MainTaxes = ids.MainTaxes,
MainTotal = ids.MainTotal,
TypeOfPortals = ids.TypeOfPortals,
TypeOfTickets = ids.TypeOfTickets,
SecondBlankSpaceForPanel2 = ids.SecondBlankSpaceForPanel2,
}).First();
var showInvoiceDetails = (from ids in context.InvoiceDetailses
where
ids.Invoiceid == showInvoices.Invoiceid
select new InvoiceDetails_Report_ViewModel()
{
}).ToList();
var querylist = new List<Invoice_Report_ViewModel> { showInvoices };
rptH.Database.Tables[0].SetDataSource(querylist);
rptH.Database.Tables[0].SetDataSource(showInvoiceDetails);
rptH.Refresh();
Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
return File(stream, "application/pdf");
請幫助我得到
錯誤數據源登錄失敗
但我沒有連接到數據庫的報告,也是我使用.NET對象
請幫