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

 

c# html 转Word--Spire.Doc

上一篇:Msql:Incorrect double value: ''for column 'id' at row 1解决


下一篇:C# 使用WebClient时,在多网卡时,指定IP发送Web请求