[英]Import Word Document Data to RDLC Report
将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 StartHTML:0000000207 EndHTML:0000068119 StartFragment:0000047434 EndFragment:0000068079 SourceURL:file://server1/folder1/file1.docx
â€
是否可以将Word模板导入RDLC报告?
尝试这个
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文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.