簡體   English   中英

將HTML轉換為Word文檔

[英]Convert HTML To Word Document

如何將頁面HTML to word轉換HTML to word文檔。 例如,我有一個網頁,我需要將其保存在Word文檔中。 如何將HTML頁面轉換為Word文檔。 以及如何在Word文檔中插入分頁符

在下面,您可以找到一個將html轉換為word的示例。

它工作正常,我已經在MS Office 2013Open Office上對其進行了測試。

注意:對於分頁符,請在行下方插入

<br clear=all style='mso-special-character:line-break;page-break-before:always'> 

例:

Dim StrLocLetterText As StringBuilder = New StringBuilder()
Dim ObjLocHtml1 As String = "<html xmlns:v=""urn:schemas-microsoft-com:vml"" xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:x=""urn:schemas-microsoft-com:office:word"" xmlns=""http://www.w3.org/TR/REC-html40""><head></head><body>"
Dim ObjLocHtml2 As String = "</body></html>"

StrLocLetterText.Append(ObjLocHtml1)
StrLocLetterText.Append(<Content within body tag>)
StrLocLetterText.Append(ObjLocHtml2)
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.ContentType = "application/msword"
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + <FileName> + ".doc")
HttpContext.Current.Response.Write(StrLocLetterText)
HttpContext.Current.Response.End()
HttpContext.Current.Response.Flush()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM