2017-03-20 17 views
1

私は以下のフォーマットの.docxフォーマットを持っています。 .docxを.htmlに変換してパスの下に保存したい:.docxをc#でhtmlファイルに変換し、それぞれのディレクトリに保存する方法は?

私は200個以上の.docxファイルを持っています。手動で.htmlに変更するのは非常に難しいです。

の.docx形式:あなたは私がこれを解決するために助けてくださいすることができます: "\ ConvertedToHTML C"

<START> 
<TITLE>UAE0d23376</TITLE> 
<BODY> 
<P>3376</P> 
<P> 
urged that he should be sent to saint winifreds, with some vague notion of making a man of him. he<br>might as well have thrown a piece of brussels lace into the fire with intention of changing it into<br>you want be troubled with this one long, said her son; ill go with me, and that's soon 
</P> 
</BODY> 
<END> 

Neadは.htmlのと下に保存するように変更します。

答えて

0

OpenXmlPowerTools.dllコードへの参照を追加します。HTML形式に

を.docxのファイルを変換:OpenXMLPoerTool.dllを追加する

using OpenXmlPowerTools; 
using DocumentFormat.OpenXml.Wordprocessing; 

byte[] byteArray = File.ReadAllBytes(DocxFilePath); 
using (MemoryStream memoryStream = new MemoryStream()) 
{ 
    memoryStream.Write(byteArray, 0, byteArray.Length); 
    using (WordprocessingDocument doc = WordprocessingDocument.Open(memoryStream, true)) 
{ 
     HtmlConverterSettings settings = new HtmlConverterSettings() 
     { 
      PageTitle = "My Page Title" 
     }; 
     XElement html = HtmlConverter.ConvertToHtml(doc, settings); 

     File.WriteAllText(HTMLFilePath, html.ToStringNewLineOnAttributes()); 
} 
} 
+0

ことができません – Dhamo

関連する問題