Wednesday, 05 January 2011 06:15

Insert Hyperlink in Excel

Excel Hyperlink guides users to get more information about data in one cell. For example, the hyperlink links text (city name) in cell to a city history webpage and can help readers learn more about a city. Besides website address, the hyperlink can be an Email address or a file. Generally speaking, if data in on cell is website address like www.e-iceblue.com or Email address, the hyperlink will be generated automatically.

Spire.XLS for .NET, a professional .NET Excel component to generate, open and write Excel files, enables users to insert hyperlink in Excel by using C#, VB.NET. This guide illustrates how to realize this function quickly via Spire.XLS for .NET.

Now, I will insert hyperlink for Text “Chicago” and the Email address besides “Chicago” cell. Invoke sheet.Hyperlinks.Add(cellRange) method to insert hyperlink for specified cell. Then, set TextToDisplay, Type, Address properties for this hyperlink.Download and install Spire.XLS for .NET. Use the following code to insert hyperlink in Excel with C#, VB.NET.

Insert Excel Hyperlink

[C#]
using Spire.Xls;

namespace ExcelHyperlink
{
    class XLSLink
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"E:\Work\Documents\ExcelFiles\Student Info.xlsx");
            Worksheet sheet = workbook.Worksheets[0];

            HyperLink UrlLink= sheet.HyperLinks.Add(sheet.Range["E8"]);
            UrlLink.TextToDisplay = sheet.Range["E8"].Text;
            UrlLink.Type=HyperLinkType.Url; 
            UrlLink.Address="http://en.wikipedia.org/wiki/Chicago";

            HyperLink MailLink = sheet.HyperLinks.Add(sheet.Range["F8"]);       
            MailLink.TextToDisplay = sheet.Range["F8"].Text;
            MailLink.Type = HyperLinkType.Url;
            MailLink.Address = "mailto:ka.Lee220@hotmail.com";

            workbook.SaveToFile("ExcelHyperlink.xlsx", ExcelVersion.Version2010);
            System.Diagnostics.Process.Start("ExcelHyperlink.xlsx");
        }
    }
}

[VB.NET]
Imports Spire.Xls

Namespace ExcelHyperlink
    Friend Class XLSLink
        Shared Sub Main(ByVal args() As String)
            Dim workbook As New Workbook()
            workbook.LoadFromFile("E:\Work\Documents\ExcelFiles\Student Info.xlsx")
            Dim sheet As Worksheet = workbook.Worksheets(0)

            Dim UrlLink As HyperLink = sheet.HyperLinks.Add(sheet.Range("E8"))
            UrlLink.TextToDisplay = sheet.Range("E8").Text
            UrlLink.Type = HyperLinkType.Url
            UrlLink.Address = "http://en.wikipedia.org/wiki/Chicago"

            Dim MailLink As HyperLink = sheet.HyperLinks.Add(sheet.Range("F8"))
            MailLink.TextToDisplay = sheet.Range("F8").Text
            MailLink.Type = HyperLinkType.Url
            MailLink.Address = "mailto:ka.Lee220@hotmail.com"

            workbook.SaveToFile("ExcelHyperlink.xlsx", ExcelVersion.Version2010)
            System.Diagnostics.Process.Start("ExcelHyperlink.xlsx")
        End Sub
    End Class
End Namespace
Tuesday, 04 January 2011 08:26

Spire.XLS Program Guide Content for .NET

Spire.XLS is a versatile Excel library that is designed for software developers to perform a wide range of Excel processing tasks on .NET, Silverlight and WPF Platform. As a combination of APIs and GUI controls, Spire.XLS does not need to install MS Excel or any third party libraries and supports to apply Excel on the formats of either Excel .xls 97-2003 or Excel .xlsx 2007, 2010 and 2013.

This API gives developers powerful tools for performing simple tasks as well as more complex tasks. Basic operation tasks such as create, save, protect and merge Excel files, add/delete/hide worksheets, edit spreadsheet cell data, generate charts can be all realized with high efficiency.


Chart

Smart Marker

Tuesday, 28 December 2010 07:50

Extract Images from Word in C#, VB.NET

Solution in this guide demonstrates how to extract images from an existing Word document and save them to a specified path in C# and VB.NET via Spire.Doc for .NET.

Image is one kind of document objects which belongs to paragraph items. Spire.Doc for .NET provides a DocumentObject class to store images in Document. And also provides a DocPicture class to get and set images of document. Download and Install Spire.Doc for .NET. Follow steps to extract images from Word.

  • Get each Paragraph of each Section in Document.
  • Get each DocumentObject of ChildObjects in Paragraph.
  • If the gotten DocumentObjectType is Picture, initialize a DocPicture class instance and assign the DocumentObject as value for this instance.
  • Initialize a String class instance to name extracted image instead of its original name by invoking String.Format(String format, object arg0)
  • Invoke DocPictrue.Image.Save(String, ImageFormat) method to save images.
[C#]
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System;
namespace ExtractImage
{

    class Program
    {
        static void Main(string[] args)
        {
            //Load document
            Document document = new Document(@"E:\Work\Documents\WordDocuments\Spire.Doc for .NET.docx");
            int index = 0;

            //Get Each Section of Document
            foreach (Section section in document.Sections)
            {
                //Get Each Paragraph of Section
                foreach (Paragraph paragraph in section.Paragraphs)
                {
                    //Get Each Document Object of Paragraph Items
                    foreach (DocumentObject docObject in paragraph.ChildObjects)
                    {
                        //If Type of Document Object is Picture, Extract.
                        if (docObject.DocumentObjectType == DocumentObjectType.Picture)
                        {
                            DocPicture picture = docObject as DocPicture;

                            //Name Image
                            String imageName = String.Format(@"images\Image-{0}.png", index);

                            //Save Image
                            picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
                            index++;
                        }
                    }
                }
            }
        }
    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields
Namespace ExtractImage

	Class Program
		Private Shared Sub Main(args As String())
			'Load document
			Dim document As New Document("E:\Work\Documents\WordDocuments\Spire.Doc for .NET.docx")
			Dim index As Integer = 0

			'Get Each Section of Document
			For Each section As Section In document.Sections
				'Get Each Paragraph of Section
				For Each paragraph As Paragraph In section.Paragraphs
					'Get Each Document Object of Paragraph Items
					For Each docObject As DocumentObject In paragraph.ChildObjects
						'If Type of Document Object is Picture, Extract.
						If docObject.DocumentObjectType = DocumentObjectType.Picture Then
							Dim picture As DocPicture = TryCast(docObject, DocPicture)

							'Name Image
							Dim imageName As [String] = [String].Format("images\Image-{0}.png", index)

							'Save Image
							picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png)
							index += 1
						End If
					Next
				Next
			Next
		End Sub
	End Class
End Namespace

After debugging, all the extracted images are saved in a specified path. Open the directory, the images will be found.

Extract Word Image

Spire.Doc, an easy-to-use component to operate Word document, allows developers to fast generate, write, edit and save Word (Word 97-2003, Word 2007, Word 2010) in C# and VB.NET for .NET, Silverlight and WPF.

Tuesday, 28 December 2010 06:45

How to Traverse a Document Tree

Spire.Doc represents a document as a tree, every document element is a node of that tree. Some nodes such as section, paragraph and table may have many child nodes. For example, a section node has several paragraph nodes, a paragraph node has many text nodes and each row is the child node of a table node. And other nodes have no child node, such as text-range, image, form-field.
If a node has child nodes, it should be an instance of Spire.Doc.Interface.ICompositeObject.
If you want to operate all the nodes, you can use the tree navigation method to visit each node.

Document Tree Traversal

The following example demonstrates how to traverse a document tree to collect all nodes and ouput the text of all text-range nodes.
[C#]
using System;
using System.Collections.Generic;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using Spire.Doc.Interface;
using Spire.Doc.Collections;

namespace ExtractText
{
    class Program
    {
        static void Main(string[] args)
        {
            //Open a word document.
            Document document = new Document("Sample.doc");
            IList<IDocumentObject> nodes = GetAllObjects(document);
            foreach (IDocumentObject node in nodes)
            {
                //Judge the object type. 
                if (node.DocumentObjectType == DocumentObjectType.TextRange)
                {
                    TextRange textNode = node as TextRange;
                    Console.WriteLine(textNode.Text);
                }
            }
        }

        private static IList<IDocumentObject> GetAllObjects(Document document)
        {
        
            //Create a list.
            List<IDocumentObject> nodes = new List<IDocumentObject>();
            
            //Create a new queue.
            Queue<ICompositeObject> containers = new Queue<ICompositeObject>();
            
            //Put the document objects in the queue.
            containers.Enqueue(document);
            while (containers.Count > 0)
            {
                ICompositeObject container = containers.Dequeue();
                DocumentObjectCollection docObjects = container.ChildObjects;
                foreach (DocumentObject docObject in docObjects)
                { 
                    nodes.Add(docObject);
                    
                    //Judge the docObject.
                    if (docObject is ICompositeObject)
                    {
                        containers.Enqueue(docObject as ICompositeObject);
                    }
                }
            }

            return nodes;
        }
    }
}
          
[VB.NET]
Imports System
Imports System.Collections.Generic
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields
Imports Spire.Doc.Interface
Imports Spire.Doc.Collections

Module Module1

    Sub Main()
        'Open a word document.
        Dim document As New Document("Sample.doc")
        Dim nodes As IList(Of IDocumentObject)() = GetAllObjects(document)
        Dim containers As New Queue(Of ICompositeObject)()

        For Each node As IDocumentObject In nodes
        
            'Judge the object type.
            If (node.DocumentObjectType = DocumentObjectType.TextRange) Then
                Dim textNode As TextRange = node
                Console.WriteLine(textNode.Text)

            End If
        Next
    End Sub
    Function GetAllObjects(ByVal document As Document) As IList(Of IDocumentObject)
        
        'Create a list.
        Dim nodes As New List(Of IDocumentObject)()
        
        'Create a new queue.
        Dim containers As New Queue(Of ICompositeObject)()
        
        'Put the document objects in the queue.
        containers.Enqueue(document)
        While (containers.Count > 0)
            Dim container As ICompositeObject = containers.Dequeue()
            Dim docObjects As DocumentObjectCollection = container.ChildObjects
            For Each docObject As DocumentObject In docObjects
                nodes.Add(docObject)
                
                'Judge the docObject.
                If TypeOf docObject Is ICompositeObject Then
                    containers.Enqueue(TryCast(docObject, ICompositeObject))
                End If
            Next
        End While

        Return nodes
    End Function
End Module
          
Tuesday, 28 December 2010 02:25

Insert Word Bookmark in C#, VB.NET

Word bookmark is convenient for users to go to specified location and modify contents of bookmark range in a document. Solution in this guide introduces how to insert bookmark in existing Word document in C# and VB.NET via Spire.Doc for .NET. In this example, the bookmark range is from the end of the fourth paragraph to the end of the fifth paragraph. The following screenshot presents effect after Work bookmark inserting.

Insert Word Bookmark

Spire.Doc for .NET, a professional .NET Word component, provides two methods to insert Word bookmark, Paragraph.AppendBookmarkStart and Paragraph.AppendBookmarkEnd with parameter string name. The former method is used to append start of the bookmark with specified name into paragraph, while the later to append end of bookmark. Download and install Spire.Doc for .NET and follow the code to insert Word bookmark.

[C#]
using System;
using Spire.Doc;
using Spire.Doc.Documents;

namespace WordBookmark
{
    class Bookmark
    {
        static void Main(string[] args)
        {
            //Load Document
            Document document = new Document();
            document.LoadFromFile(@"E:\Work\Document\.NET Framework.docx");

            //Insert Bookmark
            Section section = document.Sections[0];
            section.Paragraphs[3].AppendBookmarkStart(".NETFramework");
            section.Paragraphs[4].AppendBookmarkEnd(".NETFramework");

            //Save and Launch 
            document.SaveToFile("Bookmark.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("Bookmark.docx");
        }
    }
}
[VB.NET]
Imports System
Imports Spire.Doc
Imports Spire.Doc.Documents

Namespace WordBookmark
    Friend Class Bookmark
        Shared Sub Main(ByVal args() As String)
            'Load Document
            Dim document As New Document()
            document.LoadFromFile("E:\Work\Document\.NET Framework.docx")

            'Insert Bookmark
            Dim section As Section = document.Sections(0)
            section.Paragraphs(3).AppendBookmarkStart(".NETFramework")
            section.Paragraphs(4).AppendBookmarkEnd(".NETFramework")

            'Save and Launch 
            document.SaveToFile("Bookmark.docx", FileFormat.Docx)
            System.Diagnostics.Process.Start("Bookmark.docx")
        End Sub
    End Class
End Namespace

Spire.Doc, an easy-to-use component to operate Word document, allows developers to fast generate, write, edit and save Word (Word 97-2003, Word 2007, Word 2010) in C# and VB.NET for .NET, Silverlight and WPF.

Tuesday, 21 December 2010 16:34

Insert Header/Footer in Word Document in C#

Word header appears in the top of each page in a document, while Word footer appears in the bottom. Header and footer can be text or images, for example, document title, time and date, page numbers, company logo etc. Also, users can change or format header/footer contents according to own requirement.

Spire.Doc for .NET, a professional component to manipulate Word document with .NET, enables developers to insert header/footer in Word document by using C#/VB.NET. And this guide will show details about how to realize this function.

Users can set header or footer for Word document through HeadersFooters property of Section Class which Spire.Doc for .NET provides. Then, invoke header/footer.AddParagraph() method to add header/footer paragraph and add contents by invoking paragraph.AppendText(string) method. Now Download and Install Spire.Doc for .NET. Then, use the following code to insert header/footer in Word.

Insert Word Header

[C#]
           //Add Header
            Section section = document.Sections[0];
            HeaderFooter header = section.HeadersFooters.Header;
            Paragraph HParagraph = header.AddParagraph();
            TextRange HText = HParagraph.AppendText("Spire.Doc for .NET");

            //Set Header Text Format
            HText.CharacterFormat.FontName = "Algerian";
            HText.CharacterFormat.FontSize = 15;
            HText.CharacterFormat.TextColor = Color.RoyalBlue;

            //Set Header Paragraph Format
            HParagraph.Format.HorizontalAlignment = HorizontalAlignment.Left;
            HParagraph.Format.Borders.Bottom.BorderType=BorderStyle.ThickThinMediumGap;
            HParagraph.Format.Borders.Bottom.Space = 0.05f;
            HParagraph.Format.Borders.Bottom.Color = Color.DarkGray;
[VB.NET]
             'Add Header
            Dim section As Section = document.Sections(0)
            Dim header As HeaderFooter = section.HeadersFooters.Header
            Dim HParagraph As Paragraph = header.AddParagraph()
            Dim HText As TextRange = HParagraph.AppendText("Spire.Doc for .NET")

            'Set Header Text Format
            HText.CharacterFormat.FontName = "Algerian"
            HText.CharacterFormat.FontSize = 15
            HText.CharacterFormat.TextColor = Color.RoyalBlue

            'Set Header Paragraph Format
            HParagraph.Format.HorizontalAlignment = HorizontalAlignment.Left
            HParagraph.Format.Borders.Bottom.BorderType = BorderStyle.ThickThinMediumGap
            HParagraph.Format.Borders.Bottom.Space = 0.05F
            HParagraph.Format.Borders.Bottom.Color = Color.DarkGray

Header Result:

Insert Text Header/Footer

Insert Word Footer

[C#]
           //Add Footer
            HeaderFooter footer = section.HeadersFooters.Footer;
            Paragraph FParagraph = footer.AddParagraph();
            TextRange FText = FParagraph.AppendText("E-iceblue Co., Ltd. 2012 All Rights Reserverd");

            //Set Footer Text Format
            FText.CharacterFormat.FontName = "Calibri";
            FText.CharacterFormat.FontSize = 12;
            FText.CharacterFormat.TextColor = Color.DarkCyan;

            //Set Footer Paragrah Format
            FParagraph.Format.HorizontalAlignment = HorizontalAlignment.Right;
            FParagraph.Format.Borders.Top.BorderType=BorderStyle.ThinThinSmallGap;
            FParagraph.Format.Borders.Top.Space = 0.15f;
            FParagraph.Format.Borders.Color = Color.DarkGray;
[VB.NET]
           'Add Footer
            Dim footer As HeaderFooter = section.HeadersFooters.Footer
            Dim FParagraph As Paragraph = footer.AddParagraph()
            Dim FText As TextRange = FParagraph.AppendText("E-iceblue Co., Ltd. 2012 All Rights Reserverd")

            'Set Footer Text Format
            FText.CharacterFormat.FontName = "Calibri"
            FText.CharacterFormat.FontSize = 12
            FText.CharacterFormat.TextColor = Color.DarkCyan

            'Set Footer Paragrah Format
            FParagraph.Format.HorizontalAlignment = HorizontalAlignment.Right
            FParagraph.Format.Borders.Top.BorderType = BorderStyle.ThinThinSmallGap
            FParagraph.Format.Borders.Top.Space = 0.15F
            FParagraph.Format.Borders.Color = Color.DarkGray

Footer Result:

Insert Text Header/Footer

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.

Word Image can beautify the document to attract more readers. Generally speaking, images in Word are related to contents. For example, the image will be places of interest if the document focuses on introducing one country. Sometimes, image can describe some of contents more clearly, like using chart to show data changes in a period.

Spire.Doc for .NET, a professional .NET word component to fast generate, open, modify and save Word documents without using MS Office Automation, enables users to insert image in Word and set its size according to page by using C#, VB.NET. This guide introduces an easy method how to insert image via Spire.Doc for .NET.

At first, create new Word document and add section, page for this document. Then, use p.AppendPicture(Image) method to insert image in the new created paragraph. Set height and width property for image to format its size. Download and Install Spire.Doc for .NET. Use the following code to insert image in Word by using C#, VB.NET.

Insert Word Image

[C#]
using System.Drawing;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

namespace WordImage
{
    class ImageinWord
    {
        static void Main(string[] args)
        {
            //Create Document
            Document document = new Document();
            Section s = document.AddSection();
            Paragraph p = s.AddParagraph();

            //Insert Image and Set Its Size
            DocPicture Pic = p.AppendPicture(Image.FromFile(@"E:\Work\Documents\SampleImage\Sample.jpg"));
            Pic.Width = 750;
            Pic.Height = 468;

            //Save and Launch
            document.SaveToFile("Image.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("Image.docx");
        }
    }
}
[VB.NET]
Imports System.Drawing
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields

Namespace WordImage
    Friend Class ImageinWord
        Shared Sub Main(ByVal args() As String)
            'Create Document
            Dim document As New Document()
            Dim s As Section = document.AddSection()
            Dim p As Paragraph = s.AddParagraph()

            'Insert Image and Set Its Size
            Dim Pic As DocPicture = p.AppendPicture(Image.FromFile("E:\Work\Documents\SampleImage\Sample.jpg"))
            Pic.Width = 750
            Pic.Height = 468

            'Save and Launch
            document.SaveToFile("Image.docx", FileFormat.Docx)
            System.Diagnostics.Process.Start("Image.docx")
        End Sub
    End Class
End Namespace

Spire.Doc, an easy-to-use .NET Word component, enables users to fast generate, open, save and modify Word document on .NET, WPF and Silverlight applications without Word automation and any other third party add-ins.

Thursday, 16 December 2010 06:35

Edit Word Document in C#, VB.NET

In order to correct wrong spellings or add some new contents in a Word document, users need to edit an existing Word document. This guide demonstrates a solution to edit Word document in C# and VB.NET.

Spire.Doc for .NET, wonderful .NET Word component, offers a Paragraph class, which enables users to edit contents in paragraphs through set its properties. In this example, the title is updated and new text is added in paragraph two (Title is paragraph one). The editing result is shown as following screenshot.

Edit Word Document

Firstly, declare a Paragraph instance and its value is set as paragraph one (title). Set its Text property to update the original contents. Secondly, declare another Paragraph instance and its value is set as Paragraph two. Invoke Paragraph.AppendText method to add new contents for this paragraph. The overload passed to this method is string text. For distinguishing new contents and existing contents, new contents are formatted in this example. Declare a TextRange instance and set its value as new added contents. Set CharacterFormat properties for this TextRange, including FontName, FontSize and TextColor. Download and install Spire.Doc for .NET and follow the code below to edit Word document.

[C#]
using System.Drawing;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

namespace EidtWord
{
    class Program
    {
        static void Main(string[] args)
        {
            //Load Document
            Document document = new Document();
            document.LoadFromFile(@"E:\Work\Documents\WordDocuments\Spire.Doc for .NET.docx");

            //Update Text of Title
            Section section = document.Sections[0];
            Paragraph para1 = section.Paragraphs[0];
            para1.Text = "Spire.Doc for .NET Introduction";

            //Add New Text
            Paragraph para2 = section.Paragraphs[1];
            TextRange tr=para2.AppendText("Spire.Doc for .NET is stand-alone"
            +"to enables developers to operate Word witout Microsoft Word installed.");
            tr.CharacterFormat.FontName = "Cataneo BT";
            tr.CharacterFormat.FontSize=12;
            tr.CharacterFormat.TextColor = Color.YellowGreen;
           
            //Save and Launch
            document.SaveToFile("Edit Word.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("Edit Word.docx");
        }
    }
}
[VB.NET]
Imports System.Drawing
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields

Namespace EidtWord
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            'Load Document
            Dim document As New Document()
            document.LoadFromFile("E:\Work\Documents\WordDocuments\Spire.Doc for .NET.docx")

            'Update Text of Title
            Dim section As Section = document.Sections(0)
            Dim para1 As Paragraph = section.Paragraphs(0)
            para1.Text = "Spire.Doc for .NET Introduction"

            'Add New Text
            Dim para2 As Paragraph = section.Paragraphs(1)
            Dim tr As TextRange = para2.AppendText("Spire.Doc for .NET is stand-alone" &
                                                   "to enables developers to operate Word witout Microsoft Word installed.")
            tr.CharacterFormat.FontName = "Cataneo BT"
            tr.CharacterFormat.FontSize = 12
            tr.CharacterFormat.TextColor = Color.YellowGreen

            'Save and Launch
            document.SaveToFile("Edit Word.docx", FileFormat.Docx)
            System.Diagnostics.Process.Start("Edit Word.docx")
        End Sub
    End Class
End Namespace

Spire.Doc, an easy-to-use component to operate Word document, allows developers to fast generate, write, edit and save Word (Word 97-2003, Word 2007, Word 2010) in C# and VB.NET for .NET, Silverlight and WPF.

Tuesday, 14 December 2010 08:33

Create, Write and Save Word in C#, VB.NET

A new created Word document can be written with contents and saved to specified path. This guide demonstrates solution to create, write and save Word in C# and VB.NET.

The basic operations of Word are to generate, write contents and save. First of all, users can create a blank Word document and then write what they want to say in this document and finally save to specified path. This guide focuses on presenting how to create, write and save Word in C# and VB.NET via Spire.Doc for .NET. The screenshot below is result after programming with following steps.

Operate Word

Create Word

Spire.Doc for .NET offers a Document class to enable developers to initialize a new Document instance. This instance is a new blank Word document.

[C#]
            //Create New Word
            Document doc = new Document();
[VB.NET]
	     'Create New Word
            Dim doc As New Document()

Write Contents in Word

Generally speaking, contents are written in a paragraph which is contained in section of document. Therefore, you need to add a new section firstly by invoking method Document.AddSection(). And add a new paragraph in new section by invoking Section.AddParagraph(). After that, you can write contents in paragraph by invoking Paragraph.AppendText(string text) method.

[C#]
            //Add Section
            Section section = doc.AddSection();
            //Add Paragraph
            Paragraph Para = section.AddParagraph();
            //Append Text
            Para.AppendText("Spire.Doc for .NET, a professional .NET Word component, "
            +"enables developers to perform a large range of tasks on Word document(from Version Word97-2003 to Word 2010) "
            +"for .NET in C# and VB.NET."
            +"This libray is specially designed for .NET developers to help them"
            +"to create any WinForm and ASP.NET Web applications to create, open, write, edit, save and convert"      
            +"Word document without Microsoft Office and any other third-party tools installed on system.");
[VB.NET]
            'Add Section
            Dim section As Section = doc.AddSection()
            'Add Paragraph
            Dim Para As Paragraph = section.AddParagraph()
            'Append Text
            Para.AppendText("Spire.Doc for .NET, a professional .NET Word component, " & "enables developers to perform a large range of tasks on Word document(from Version Word97-2003 to Word 2010) " & "for .NET in C# and Visual Basic." & "This libray is specially designed for .NET developers to help them" & "to create any WinForm and ASP.NET Web applications to create, open, write, edit, save and convert" & "Word document without Microsoft Office and any other third-party tools installed on system.")

Save Word

Invoke SaveToFile method of Document class to save the written Word. The parameter passed to this method is string fileName. If you want to set extension as .doc or .docx, you need to pass the other parameter FileFormat fileFormat to this method.

[C#]
            //Save Word
            doc.SaveToFile("OperateWord.docx", FileFormat.Docx);
[VB.NET]
            'Save Word
            doc.SaveToFile("OperateWord.docx", FileFormat.Docx)

Spire.Doc, professional Word component, is specially designed for developers to fast generate, write, modify and save Word documents in .NET, Silverlight and WPF with C# and VB.NET. Also, it supports conversion between Word and other popular formats, such as PDF, HTML, Image, Text and so on, in .NET and WPF platform.

Tuesday, 14 December 2010 07:23

Spire.Doc Program Guide Content for .NET

Spire.Doc, specially designed for developers/programmers to manipulate word proceeding tasks, from Word version 97-2003 to 2010 and 2013 in .NET, Silverlight and WPF Platform, always welcomes any kind of evaluation or test from either organizations or individuals with no charges.

This professional word library enables users to perform a large range of tasks on Word, as document operation (create, open, edit and save), mail merge, security, format (font, paragraph and page settings), objects (text, image, hyperlink, comment, table, bookmark, header/footer, footnote/endnote etc.). The conversion feature stands out of the peers, which enables developers to realize conversion between most popular formats with high fidelity, including Word to PDF, HTML, RTF, XML, Image formats, TEXT and RTF, XML and HTML files also can be converted to Word back. The following sections have been well-organized to show you how these functions work in detail.