将Word文档数据(文本,项目符号,图像)追加到RDLC报告中。
当前,我(未成功)通过ReportParameter将Word文档数据附加到报表的末尾。
...
ReportViewer1.LocalReport.SetParameters(New ReportParameter("rpReportTemplate", GetWordData(WordDocumentPath)))
...
Public Function GetWordData(ByVal wordPath As String) As String
Dim MyWord As Microsoft.Office.Interop.Word.Application
Dim sConvertedString As String = ""
MyWord = CreateObject("Word.application")
MyWord.Visible = False
MyWord.Documents.Open(wordPath)
MyWord.Windows(1).Selection.WholeStory()
MyWord.Windows(1).Selection.Copy()
MyWord.Quit()
sConvertedString = Clipboard.GetData(DataFormats.Html)
Return sConvertedString
End Function
我似乎无法将图像放入报告中。我得到一些奇怪的HTML文本,也得到了奇怪的文本字符:
版本:1.0起始HTML:0000000207结束HTML:0000068119 StartFragment:0000047434 EndFragment:0000068079 SourceURL:file://server1/folder1/file1.docx
â€
是否可以将Word模板导入RDLC报告?
答案 0 :(得分:0)
尝试
protected void Page_Load(object sender, EventArgs e)
{
LocalReport report = new LocalReport();
report.ReportPath = "Report1.rdlc";
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";
//This refers to the dataset name in the RDLC file
rds.Value = EmployeeRepository.GetAllEmployees();
report.DataSources.Add(rds);
Byte[] mybytes = report.Render("WORD");
//Byte[] mybytes = report.Render("PDF"); for exporting to PDF
using (FileStream fs = File.Create(@"D:\wordfile.doc"))
{
fs.Write(mybytes, 0, mybytes.Length);
}
}
并将您的rdlc报告导出到Word文件