Knowledgebase (2328)
Children categories
Spire.DataExport for .NET is a professional .NET DataExport library, enables users to export data from database, datatable and other datasoure to MS Excel, MS Word, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV and MS Clipboard without MS Office, Adobe Acrobat and other third-party installed on system. With Spire.DataExport, developer can create any WinForm and Web applications to export data.
Spire.DataExport is fantastic on formatting when exporting, especially for Excel. Users can format data, import formula, insert objects (image, hyperlinks etc.) and create chart when export a large amount of data to multiple worksheets. The following sections will present how to quickly export data in details.
Rich Text Format (RTF) is a proprietary text file format which can serve as an exchange format between word processing programs from different manufacturers on different operating systems. Rich text documents include page formatting options, such as custom page margins, line spacing, and tab widths. With rich text, it's easy to create columns, add tables, and format your documents in a way that makes them easier to read. This article will demonstrate how to convert Word Doc/Docx to RTF files and convert RTF to Word Doc/Docx with the help of Spire.Doc for .NET.
Install Spire.Doc for .NET
To begin with, you need to add the DLL files included in the Spire.Doc for.NET package as references in your .NET project. The DLLs files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Doc
Convert Word Doc/Docx to RTF
The following steps show you how to convert Word to RTF using Spire.Doc for .NET.
- Create a Document instance.
- Load a Word sample document using Document.LoadFromFile() method.
- Save the document as an RTF file using Document.SaveToFile() method.
- C#
- VB.NET
using Spire.Doc;
namespace ConvertToRtf
{
class Program
{
static void Main(string[] args)
{
//Create a Word document instance
Document document = new Document();
//Load a Word sample document
document.LoadFromFile("sample.docx");
// Save the document to RTF
document.SaveToFile("Result.rtf", FileFormat.Rtf);
}
}
}

Convert RTF to Word Doc/Docx
The steps to convert an RTF document to Word Doc/Docx is very similar with that of the above example:
- Create a Document instance.
- Load an RTF document using Document.LoadFromFile() method.
- Save the RTF document to Doc/Docx format using Document.SaveToFile() method.
- C#
- VB.NET
using Spire.Doc;
using System;
public class RtfToDocDocx
{
public static void Main(String[] args)
{
// Create a Document instance
Document document = new Document();
// Load an RTF document
document.LoadFromFile("input.rtf", FileFormat.Rtf);
// Save the document to Doc
document.SaveToFile("toDoc.doc", FileFormat.Doc);
// Save the document to Docx
document.SaveToFile("toDocx.docx", FileFormat.Docx2013);
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
OpenXML is an XML-based file format for MS Office documents. OpenXML is popular among developers as it allows creating and editing Office documents, such Word documents, with no need for MS Office. But when presented to ordinary users, OpenXML files usually need to be converted to Word documents to facilitate reading and editing. In this article, you can learn how to convert XML files to Word documents or Word documents to XML files with the help of Spire.Doc for .NET.
Install Spire.Doc for .NET
To begin with, you need to add the DLL files included in the Spire.Doc for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Doc
Convert an OpenXML File to a Word Document
The detailed steps of the conversion are as follows:
- Create an object of Document class.
- Load an OpenXML file from disk using Document.LoadFromFile() method.
- Convert the OpenXML file to a Word document and save it using Document.SaveToFile() method.
- C#
- VB.NET
using Spire.Doc;
using System;
namespace DocExample
{
internal class Program
{
static void Main(string[] args)
{
//Create a Document class instance
Document document = new Document();
//Load an OpenXML file from disk
document.LoadFromFile(@"C:\Samples\Sample.xml", FileFormat.Xml);
//Convert the OpenXML file to a Word document and save it
document.SaveToFile("OpenXMLToWord.docx", FileFormat.Docx2013);
}
}
}

Convert a Word Document to an OpenXML File
The detailed steps of the conversion are as follows:
- Create an object of Document class.
- Load a Word document from disk using Document.LoadFromFile() method.
- Convert the Word document to an OpenXML file and save it using Document.SaveToFile() method.
- C#
- VB.NET
using Spire.Doc;
using System;
namespace DocExample
{
internal class Program
{
static void Main(string[] args)
{
//Create a Document class instance
Document document = new Document();
//Load a Word document from disk
document.LoadFromFile(@"C:\Samples\Sample.docx");
//Convert the Word document to an OpenXML file and save it
//Change WordXML to WordML to convert to ML file
document.SaveToFile("WordToOpenXMl.xml", FileFormat.WordXml);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.


