Three Steps to Save Html File as Word Document with C#, VB.NET
Blog author: Lacy
| Posted on: 5/27/2012 | Category: C# Blogs
| Views: 2186 | Status: [Member]
| Points: 75
| Alert Moderator
Html format has its specified character which cannot be replaced by other formats. So we often need to convert one format to multiple formats. Thus, the conversion software or applications with the conversion function is necessary. For word application Spire.Doc users, it not only can save word as different formats but also can be converted by other formats, such as html and xml. Today, I am glad to share with the method how to save html as word with C#,VB.NET.
You may say that you do not need to save html as word with C#/VB.NET since you can use the copy and paste function, or you can right click the html file to edit it and then it automatically opened as word document. Both ways can realize the conversion. In some sense, you are right. However, for some basic and simple html files without image, you can easily do that through the methods above. But for those have images and a little complex, that measure is not available. When you edit the html, CSS is very likely to be ignored. So, using the method of save html as word with C#,VB.NET becomes a best and most reliable mean. I use Spire.Doc to help me finish this task in a fast way.
Step1. Load a html file from the system.
Step2. Convert HTML to Word.
Step3. Preview the effect.
static void Main(string args)
Document document = new Document();
document.LoadFromFile(@"E:\TestScript\Sample.html", FileFormat.Html, XHTMLValidationType.None);
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim document As New Document()
From the above procedure, you can obviously see that using Spire.Doc to save html as word with C#,VB.NET is not more complex than copy and paste function and edit methods. It is the most effective way to help people realize the conversion function. Not only html to word and xml to word conversion, but also word to epub, html, xml, tiff, rtf, tiff image, image and so on.
Found interesting? Add this to: