先引入Spire,代码如下:
static void Main(string[] args)
{
string str = @"
<body>
王达 线上测试<br/>
<img src='/img.jpg'/>
<br/>测试
";
string filePath = "D://HTMLPage2.html";//这里是你的已知文件
FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(str);
sw.Close();
Process p = new Process();
p.StartInfo.FileName = filePath;
p.Start();
//创建Document实例
Document document = new Document();
//加载HTML文档
document.LoadFromFile(filePath, FileFormat.Html, XHTMLValidationType.None);
//保存为Word
document.SaveToFile("D://HTMLPage111.doc", FileFormat.Docx);
document.Close();
}