c# html 转Word--Spire.Doc


利用 Spire.Doc 组件,NuGet搜索“FreeSpire.Doc”有个免费版.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using Spire.Doc;
using Spire.Doc.Documents;
using System.IO;

public static void htmltoWord(string sFile)
{
//sFile = @"E:\work\documents\TestSample.html";
//Load Document
Document document = new Document();
TextReader r = File.OpenText(sFile);
document.LoadHTML(r,XHTMLValidationType.None);
//Convert Word to PDF
document.SaveToFile("toDoc.doc", FileFormat.Docx);
//Launch Document
System.Diagnostics.Process.Start("toDoc.doc");
}

 

 

 

更多官方参考:https://www.e-iceblue.com/Introduce/word-for-net-introduce/Demo.html#.XP-2Nnot0dU

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM