1
我正在使用Microsoft.Office.Interop.Word將html轉換爲word.I在本地機器上創建html文件,然後將其轉換爲word文件。但是word文件未顯示正確的格式。它只是顯示圖像。我提到了stackoverflow的問題,但我發現沒有運氣。 我的樣本HTML文件,如下圖所示: - 如下圖所示將html轉換爲word c#
<!doctype html>
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<title="Device Information" />
<style>
table.main {
width: 700px;
height: 450px;
background: radial-gradient(#1367AB 0%, #154075 60%);
}
td.firsttablerow1 {
width: 190px;
}
td.firsttablerow2 {
width: auto;
color: white;
}
tr.image1 {
margin: "15px,20px,30px,40px";
align-items: stretch;
height: 100px;
}
tr.image2 {
margin: "0px,20px,30px,40px";
align-items: stretch;
}
tr.text1 {
color: #DDE9F2;
align-items: flex-end;
font-size: 9;
}
</style>
</head>
<body>
<table align="center" class="main">
<tr>
<td class="firsttablerow1">
<table>
<tr class="image1">
<td>
<img src='C:\Jellyfish.jpg' width='200' height='90'>
</td>
</tr>
<tr class="image2">
<td>
<img src='C:\Desert.jpg' width='150' height='90'>
</td>
</tr>
<tr class="text1">
<td>"abc"</td>
</tr>
</table>
</td>
<td class="firsttablerow2">"xyz"</td>
</tr>
</table>
</body>
</html>
我的C#代碼將HTML轉換成字。
MSWord.Application word = new MSWord.Application { Visible = false };
word.Documents.Open("htmlfilename", Format: WdOpenFormat.wdOpenFormatWebPages);
MSWord.Document doc = word.Documents[@"htmlfilename"];
doc.SaveAs2(@"wordFileName", WdSaveFormat.wdFormatDocument);
doc.Close();
doc = null;
word.Quit();
word = null;
編輯: - 後進一步調查,我發現這個詞是越來越。但它是無法使用徑向漸變。是有任何其他方式增加徑向背景改變的背景產生的?
我想這個代碼,但我得到的顯示相同output.only圖像。 – Alex