0
我正在使用RDLC文件呈現報表(無SQL Server Reporting Services)並將其從我的控制器作爲文件返回。這是我的MVC Web應用程序的一部分。無法在RDLC報表中呈現圖表
public ActionResult Index()
{
var report = new LocalReport();
report.ReportPath = Path.Combine(Server.MapPath("~/Reports"), "Report1.rdlc");
var reportData = new List<MonthlyData> {
new MonthlyData {RecordNo=1, Tid="123456", Active=10, Inactive=1}
};
ReportDataSource rd = new ReportDataSource("DataSet1", reportData);
report.DataSources.Add(rd);
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>" + "PDF" + "</OutputFormat>" +
//" <PageWidth>8.5in</PageWidth>" +
//" <PageHeight>11in</PageHeight>" +
//" <MagroupinTop>0.5in</MagroupinTop>" +
//" <MagroupinLeft>1in</MagroupinLeft>" +
//" <MagroupinRight>1in</MagroupinRight>" +
//" <MagroupinBottom>0.5in</MagroupinBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = report.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
return File(renderedBytes, mimeType);
}
這是結果:
一切就像一個魅力,直到我決定添加一個圖表。
現在,當我呈現它,我得到兩個例外:
Microsoft.Reporting.WebForms.LocalProcessingException: „An error occurred during local report processing.」
DefinitionInvalidException: The definition of the report 'C:\Users\agutowski\Documents\Visual Studio 2017\Projects\rdlcMvc\rdlcMvc\Reports\Report1.rdlc' is invalid.
和
Microsoft.Reporting.WebForms.LocalProcessingException: „An error occurred during local report processing.」
ReportProcessingException: The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.
我已經嘗試過不同的版本Microsoft.ReportViewer.Common和Microsoft.ReportViewer的.WebForms。
請包含位於'\ Program Files \ MSBuild \ Microsoft \ VisualStudio \ [版本] \ ReportingServices \ Microsoft.ReportingServices.targets'中的報告目標文件的內容。我認爲它應該包含像這樣的ReportViewer程序集:Microsoft.ReportViewer.WebForms Version = [version],Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'。 –
在'C:\ Program Files \ MSBuild \ Microsoft'下沒有VisualStudio文件夾。我應該補充一點,我沒有使用管理員帳戶。 – gutowskiap
你有使用中文本地化的'ReportViewer'嗎?我認爲可以通過從部署包中刪除中文本地化DLL(從發佈中排除)來解決這個問題。嘗試排除路徑中以'zh- *'開頭的所有路徑。 –