vb word存为html,Convert Word to HTML in C#, VB.NET

Word to html conversion enables programmers and developers to create html through editing and degining word. Finally convert word to html. This section will introduce a solution to convert word to html via a .NET Word component with C#, VB.NET.

Spire.Doc for .NET, a professional word component, without installing MS Word, enables you to convert word to html with two lines of key code. One is Document.LoadFromFile(string fileName) method which is used to load your word file from system. The other is Document.SaveToFile(string fileName, FileFormat fileFormat) that is responsible to save word as html file.

Here you can view the effect of word to html conversion task. Please feel free to download Spire.Doc for .NET and view the detail code after the picture above.

cf20950f4745ad8bf0d7e6d4dc0fd0c6.png

[C#]

using Spire.Doc;

using Spire.Doc.Documents;

namespace Word_to_HTML

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

//Create word document

Document document = new Document();

document.LoadFromFile(@"..\wordtohtml.doc");

//Save doc file to html

document.SaveToFile("toHTML.html", FileFormat.Html);

WordDocViewer("toHTML.html");

}

private void WordDocViewer(string fileName)

{

try

{

System.Diagnostics.Process.Start(fileName);

}

catch { }

}

}

}

[VB.NET]

Imports Spire.Doc

Imports Spire.Doc.Documents

Namespace Word_to_HTML

Public Class Form1

Inherits Form

Public Sub New()

MyBase.New

InitializeComponent

End Sub

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)

'Create word document

Dim document As Document = New Document

document.LoadFromFile("..\wordtohtml.doc")

'Save doc file to html

document.SaveToFile("toHTML.html", FileFormat.Html)

WordDocViewer("toHTML.html")

End Sub

Private Sub WordDocViewer(ByVal fileName As String)

Try

System.Diagnostics.Process.Start(fileName)

Catch As System.Exception

End Try

End Sub

End Class

End Namespace

Spire.Doc is a Microsoft Word component, which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF, .NET and Silverlight.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值