1
単語のエクスポート機能を作ろうとしていますが、コンテンツにhtmlタグがあります。私はこのコンテンツをhtmlファイルに入れました。を<
に置き換えました。これは私が望むものではありません。C#<を<HTMLファイルに置き換えてください。
誰かがこれを手伝ってくれますか?
私はオフィスの相互運用単語を使用して、ここで私が今使っコードです:
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
Document doc = app.Documents.Open(FileName: @"C:\Users\example\Documents\Template.docx", ReadOnly: false);
app.Selection.Find.Execute("<Index>");
app.Selection.TypeText("<h1>hello</h1>");
doc.SaveAs2(@"C:\Users\krisb\Documents\voorbeeld.html", FileFormat: WdSaveFormat.wdFormatWebArchive);
doc.Close();
Document doc1 = app.Documents.Open(FileName: @"C:\Users\example\Documents\voorbeeld.html", ReadOnly: false);
app.Selection.Find.Execute("<");
app.Selection.TypeText("<");
app.Selection.Find.Execute(">");
app.Selection.TypeText(">");
doc1.SaveAs2(@"C:\Users\example\Documents\template.docx", FileFormat: WdSaveFormat.wdFormatDocumentDefault);
doc1.Close();
Document doc2 = app.Documents.Open(FileName: @"C:\Users\example\Documents\kristemplate.docx", ReadOnly: false);
doc2.SaveAs2(@"C:\Users\example\Documents\kristemplate.pdf", FileFormat: WdSaveFormat.wdFormatPDF);
app.Quit();`
_ "<" <? "で置き換えられますか? – SeM
いいえ、htmlファイルにhtmlファイルを置き換えた場合、<< –
と置き換えてください。その部分で質問を修正してください。 – SeM