1
私はMicrosoft.Office.Interop.Wordを使用してhtmlを単語に変換しています。ローカルマシン上にhtmlファイルを作成してからword file.Butに変換すると、正しい形式が表示されません。それは単にイメージを表示しています。私はstackoverflowの質問を参照しました。しかし、私は運が見つかりませんでした。以下に示すように マイサンプルHTMLファイルがある: -htmlを単語に変換する#
<!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>
単語にHTMLに変換するマイC#コードを以下に示す通りです。
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;
編集:さらに調査-after、私は放射状の背景を追加するための他の方法を放射状の勾配.Isを使用して背景を変更することができない.But、その単語が作成取得されましたか?
私はこのコードを試してみましたが、私は同じoutput.only画像が表示されている取得しています。 – Alex