如何在WPF中将html字符串转换为MS Word文档 [英] How to convert html string to MS word document in WPF
本文介绍了如何在WPF中将html字符串转换为MS Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用WPF,VB.net。从我的一个函数,我将收到一个html字符串,我需要将其转换为MS word文档。我已将字符串复制到剪贴板中并尝试将其粘贴到word文档上。但它只显示为html字符串。如何将html字符串转换或加载为word文档。
Hi,
I'm using WPF, VB.net. From one of my function, i will receive a html string, which i need to convert into MS word document. I have copied the string into clipboard and tried to paste it on word document. But it is displaying as a html string only. How can a convert or load html string as word document.
推荐答案
Dim msword As New Document
Dim app As New Word.Application
app.Visible = True
'app.Documents.Add()
app.Documents.Open(FileName:=C:\ Users\Admin\Desktop\MyHTML.html,ConfirmConversions:= False,ReadOnly:= _
False,AddToRecentFiles:= False,PasswordDocument:=,PasswordTemplate:= _
,Revert:= False,WritePasswordDocument:=,WritePasswordTemplate:=,_
格式:= WdOpenFormat.wdOpenFormatAuto,XMLTransform:=)
'msword.ExportAsFixedFormat(C:\ Users \Admin \Desktop\Doc112.pdf)
msword.SaveAs(C:\ Users \Admin \Desktop\Doc1.pdf,Word.WdSaveFormat.wdFormatPDF)
Dim msword As New Document
Dim app As New Word.Application
app.Visible = True
'app.Documents.Add()
app.Documents.Open(FileName:="C:\Users\Admin\Desktop\MyHTML.html", ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=WdOpenFormat.wdOpenFormatAuto, XMLTransform:="")
'msword.ExportAsFixedFormat("C:\Users\Admin\Desktop\Doc112.pdf")
msword.SaveAs("C:\Users\Admin\Desktop\Doc1.pdf", Word.WdSaveFormat.wdFormatPDF)
这篇关于如何在WPF中将html字符串转换为MS Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文