Spire.Doc (114)
Children categories
Word tables can be removed if the data information isn’t related to document contents or unnecessary any more. In this example, the solution to remove the specified Word table(first one in example) in C# and Visual Basic with Spire.Doc for .NET. And the following screenshot presents original Word document with the first table.

Spire.Doc for .NET provides a RemoveAt(int index) method of TableCollection class to remove specified table in Word document. Because tables are stored in Section, so it needs to get specified Section of Document at first. Then invoke TableCollection.RemoveAt method to remove specified tables. Download and Install Spire.Doc for .NET and follow the code.
using Spire.Doc;
namespace RemoveTable
{
class Program
{
static void Main(string[] args)
{
//Load Document
Document doc = new Document(@"E:\Work\Documents\.NET Framework.docx");
//Remove the First Table
doc.Sections[0].Tables.RemoveAt(0);
//Save Document
doc.SaveToFile("RemoveTable.docx", FileFormat.Docx);
}
}
}
VB.NET code for converting Excel to HTML
Imports Spire.Doc
Namespace RemoveTable
Friend Class Program
Shared Sub Main(ByVal args() As String)
'Load Document
Dim doc As New Document("E:\Work\Documents\.NET Framework.docx")
'Remove the First Table
doc.Sections(0).Tables.RemoveAt(0)
'Save Document
doc.SaveToFile("RemoveTable.docx", FileFormat.Docx)
End Sub
End Class
End Namespace
After debugging and opening the saved document, you can find that the first table of document has been removed.

Spire.Doc, a professional Word component, enables developers/programmers to operate Word document, for example, generating, opening, saving and modifying on .NET, WPF and Silverlight applications
EPub is one format of electronic book to display contents with the most appropriate reading mode. Therefore, Word document is usually converted to EPub to give readers a more wonderful reading effect. This guide demonstrates a solution to convert Word to EPub in C# and Visual Basic easily with Spire.Doc for .NET. The following screenshot shows the converted EPub file from Word.

Spire.Doc for .NET provides a SaveToFile(String fileName, FileFormat fileFormat) method of Document class to convert Word to EPub or other document format. When invoking this method to convert Word to EPub, extension of parameter String fileName should be .epub and enum FileFormat should be chosen as EPub among options. Download and install Spire.Doc for .NET and follow the code:
using Spire.Doc;
namespace WordtoEPUB
{
class Epub
{
static void Main(string[] args)
{
//Load Document
Document document = new Document();
document.LoadFromFile(@"E:\Work\Documents\Spire.Doc for .NET.docx");
//Convert Word to EPub
document.SaveToFile("ToEpub.epub", FileFormat.EPub);
System.Diagnostics.Process.Start("ToEpub.epub");
}
}
}
Imports Spire.Doc
Namespace WordtoEPUB
Friend Class Epub
Shared Sub Main(ByVal args() As String)
'Load Document
Dim document As New Document()
document.LoadFromFile("E:\Work\Documents\Spire.Doc for .NET.docx")
'Convert Word to EPub
document.SaveToFile("ToEpub.epub", FileFormat.EPub)
System.Diagnostics.Process.Start("ToEpub.epub")
End Sub
End Class
End Namespace
Spire.Doc, the professional stand-alone component to manipulate MS Word document without automation, enables developers to generate, read, write, modify Word document on their .NET, WPF and Silverlight application.
To merge Word is to collect contents from several documents and then put them into one. Users can have an order to merge Word according to contents of document. This guide focuses on demonstrating the solution to merge Word in C# and Visual Basic with Spire.Doc for .NET. In this example, two documents will be merged. In the merged Word, the contents of the second document follow the first one. The following screenshot presents effect after merging.

Download and install Spire.Doc for .NET and follow steps to merge Word. At first, initialize two Document instances DocOne and DocTwo from specified documents. Secondly, get each section of DocTwo and invoke Document.Sections.Add method to add a new section in DocOne with parameter section which is sections in DocTwo gotten by invoking Section.Clone() method. Use foreach statement to add all the sections from DocTwo to DocOne to merge. Finally, save the merged document. Code as following:
using Spire.Doc;
namespace MergeDocument
{
class DocxMerge
{
static void Main(string[] args)
{
//Load Document1 and Document2
Document DocOne = new Document();
DocOne.LoadFromFile(@"E:\Work\Document\welcome.docx", FileFormat.Docx);
Document DocTwo = new Document();
DocTwo.LoadFromFile(@"E:\Work\Document\New Zealand.docx", FileFormat.Docx);
//Merge
foreach (Section sec in DocTwo.Sections)
{
DocOne.Sections.Add(sec.Clone());
}
//Save and Launch
DocOne.SaveToFile("Merge.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("Merge.docx");
}
}
}
Imports Spire.Doc
Namespace MergeDocument
Friend Class DocxMerge
Shared Sub Main(ByVal args() As String)
'Load Document1 and Document2
Dim DocOne As New Document()
DocOne.LoadFromFile("E:\Work\Document\welcome.docx", FileFormat.Docx)
Dim DocTwo As New Document()
DocTwo.LoadFromFile("E:\Work\Document\New Zealand.docx", FileFormat.Docx)
'Merge
For Each sec As Section In DocTwo.Sections
DocOne.Sections.Add(sec.Clone())
Next sec
'Save and Launch
DocOne.SaveToFile("Merge.docx", FileFormat.Docx)
System.Diagnostics.Process.Start("Merge.docx")
End Sub
End Class
End Namespace
Spire.Doc, the professional stand-alone component to manipulate MS Word document without automation, enables developers to generate, read, write, modify Word document on their .NET, WPF and Silverlight application.
