Reporting services 以word文档形式呈现RDLC报告(以docx形式,而不是以doc形式)
我们需要直接以Word或PDF格式生成RDLC报告,而无需使用报告查看器。这里我们有两个问题 1使用WORDOPENXML格式将报告呈现为docx时。MS Word 2013无法打开生成的文件。它给出了以下错误: 很抱歉,我们无法打开docx,因为我们发现其内容有问题 文件已损坏,无法打开 但是,它可以使用WORD格式生成为文档。这样就可以成功地打开它 但如果可能的话,我更喜欢将其生成为Docx 2尽管我们可以将其生成为文档文件,但标题部分中的背景图像丢失。我们已将信头用作报告的背景图像Reporting services 以word文档形式呈现RDLC报告(以docx形式,而不是以doc形式),reporting-services,rdlc,Reporting Services,Rdlc,我们需要直接以Word或PDF格式生成RDLC报告,而无需使用报告查看器。这里我们有两个问题 1使用WORDOPENXML格式将报告呈现为docx时。MS Word 2013无法打开生成的文件。它给出了以下错误: 很抱歉,我们无法打开docx,因为我们发现其内容有问题 文件已损坏,无法打开 但是,它可以使用WORD格式生成为文档。这样就可以成功地打开它 但如果可能的话,我更喜欢将其生成为Docx 2尽管我们可以将其生成为文档文件,但标题部分中的背景图像丢失。我们已将信头用作报告的背景图像 Re
ReportViewer reportViewer = new ReportViewer();
LocalReport localReport = new LocalReport();
localReport.ReportPath = Path.Combine(_env.ReportPath, "RollReport.rdlc");
//Set the datasource for the report
localReport.DataSources.Clear();
localReport.DataSources.Add(new ReportDataSource("Details", dtBCDetails));
localReport.DataSources.Add(new ReportDataSource("Properties", dtPropDetails));
localReport.DataSources.Add(new ReportDataSource("Insurence", dtInsurence));
localReport.DataSources.Add(new ReportDataSource("PropertyOwners", dtPropertyOwners));
//Pass parameters to the report
localReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter("BodyCorporateID", bcid.ToString()) });
localReport.Refresh();
//Get the byte stream for the report rendered as PDF
byte[] bytes = localReport.Render(format, null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
Stream repStream = new MemoryStream(bytes);
以PDF格式生成报告时没有问题
以下是用于生成报告的代码
ReportViewer reportViewer = new ReportViewer();
LocalReport localReport = new LocalReport();
localReport.ReportPath = Path.Combine(_env.ReportPath, "RollReport.rdlc");
//Set the datasource for the report
localReport.DataSources.Clear();
localReport.DataSources.Add(new ReportDataSource("Details", dtBCDetails));
localReport.DataSources.Add(new ReportDataSource("Properties", dtPropDetails));
localReport.DataSources.Add(new ReportDataSource("Insurence", dtInsurence));
localReport.DataSources.Add(new ReportDataSource("PropertyOwners", dtPropertyOwners));
//Pass parameters to the report
localReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter("BodyCorporateID", bcid.ToString()) });
localReport.Refresh();
//Get the byte stream for the report rendered as PDF
byte[] bytes = localReport.Render(format, null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
Stream repStream = new MemoryStream(bytes);
任何帮助都将不胜感激。
非常感谢。
Wijitha不知道,如果你还需要这些信息,但我至少可以在文档方面帮你。。。如果使用WORDOPENXML而不是WORD作为格式参数,则会生成一个docx文件