2
我想將.docx文件轉換爲.html。我在C#工作。我的代碼是這樣的:將.docx轉換爲html
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document wordDoc = new Microsoft.Office.Interop.Word.Document();
Object oMissing = System.Reflection.Missing.Value;
wordDoc = word.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
word.Visible = false;
Object filepath = @"C:\Users\John\Desktop\begin.docx";
Object confirmconversion = System.Reflection.Missing.Value;
Object readOnly = false;
Object saveto = @"C:\Users\John\Desktop\result.html";
Object oallowsubstitution = System.Reflection.Missing.Value;
wordDoc = word.Documents.Open(ref filepath, ref confirmconversion, ref readOnly, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing);
object fileFormat = WdSaveFormat.wdFormatHTML;
wordDoc.SaveAs(ref saveto, ref fileFormat, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oallowsubstitution, ref oMissing,
ref oMissing);
問題是,這不包括頁眉和頁腳。它們不在.html結果文件中。我如何將它們包含在結果中?
你有沒有試過手動操作?我的意思是從Word保存到HTML。它是否包含頁眉和頁腳? – Snowbear
是的,我試過了,但沒有。 –
是一個(商業)圖書館的選擇嗎? – Yahia