Formatting text in Excel in C#

2014-12-29 08:07:50 Written by support iceblue

Spire.XLS can help developers to write rich text into the spreadsheet easily, such as set the text in bold, italic, and set the colour and font for them. We have already shown you how to set Subscript and Superscript in Excel files by using Spire.XLS. This article will focus on demonstrate how to formatting text in Excel sheet in C#.

Spire.Xls offers ExcelFont class and developers can format the text of cells easily. By using RichText, we can add the text into cells and set font for it. Here comes to the steps of how to write rich text into excel cells.

Step 1: Create an excel document and get its first worksheet.

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

Step 2: Create the fonts and sent the format for each font.

//create a font and set the format to bold.
ExcelFont fontBold = workbook.CreateFont();
fontBold.IsBold = true;

//create a font and set the format to underline.              
ExcelFont fontUnderline = workbook.CreateFont();
fontUnderline.Underline = FontUnderlineType.Single;

//create a font and set the format to italic.            
ExcelFont fontItalic = workbook.CreateFont();
fontItalic.IsItalic = true;

//create a font and set the color to green.            
ExcelFont fontColor = workbook.CreateFont();
fontColor.KnownColor = ExcelColors.Green;

Step 3: Set the font for specified cell range.

RichText richText = sheet.Range["A1"].RichText;
richText.Text="It is in Bold";
richText.SetFont(0, richText.Text.Length-1, fontBold);
  
richText = sheet.Range["A2"].RichText;
richText.Text = "It is underlined";
richText.SetFont(0, richText.Text.Length-1, fontUnderline);

richText = sheet.Range["A3"].RichText;
richText.Text = "It is Italic";
richText.SetFont(0, richText.Text.Length - 1, fontItalic);

richText = sheet.Range["A4"].RichText;
richText.Text = "It is Green";
richText.SetFont(0, richText.Text.Length - 1, fontColor);

Step 4: Save the document to file.

workbook.SaveToFile("Sample.xls",ExcelVersion.Version97to2003);

Effective screenshot of writing rich text into excel worksheet:

Formatting text in Excel in C#

Full codes:

using Spire.Xls;
namespace WriteRichtextinExcel
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            ExcelFont fontBold = workbook.CreateFont();
            fontBold.IsBold = true;

            ExcelFont fontUnderline = workbook.CreateFont();
            fontUnderline.Underline = FontUnderlineType.Single;

            ExcelFont fontItalic = workbook.CreateFont();
            fontItalic.IsItalic = true;

            ExcelFont fontColor = workbook.CreateFont();
            fontColor.KnownColor = ExcelColors.Green;

            RichText richText = sheet.Range["A1"].RichText;
            richText.Text = "It is in Bold";
            richText.SetFont(0, richText.Text.Length - 1, fontBold);

            richText = sheet.Range["A2"].RichText;
            richText.Text = "It is underlined";
            richText.SetFont(0, richText.Text.Length - 1, fontUnderline);

            richText = sheet.Range["A3"].RichText;
            richText.Text = "It is Italic";
            richText.SetFont(0, richText.Text.Length - 1, fontItalic);

            richText = sheet.Range["A4"].RichText;
            richText.Text = "It is Green";
            richText.SetFont(0, richText.Text.Length - 1, fontColor);

            workbook.SaveToFile("Sample.xls", ExcelVersion.Version97to2003);

        }
    }
}

Zoom is a basic as well useful function in any text file reader. Users can chose to zoom out or zoom in of a document depending on how small the font is, or on their own view preference. In this article, I’ll introduce two ways to zoom Word file using Spire.DocViewer:

  • Zoom with a particular zoom mode
  • Zoom by entering a percentage

Now, I will explain more by creating a Windows Forms Application. Some steps about how to add DocVierwer control to toolbox and how to open Word file using Spire.DocViewer have been demonstrated previously. In the following section, I only add a MenuItem and a TextBox to Form1.

In the MenuItem, named Zoom, I create three sub-items which are used to save three particular zoom modes.

  • Default: View page in its original size.
  • Fit to page: When this option is selected, the document will be resized to match the dimensions of your view window.
  • Fit to width: When this option is selected, the document will best fit to width of window.

Code behind:

        private void defaultToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.docDocumentViewer1.ZoomMode = ZoomMode.Default;
        }
        private void fitToPageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.docDocumentViewer1.ZoomMode = ZoomMode.FitPage;
        }
        private void fitToWidthToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.docDocumentViewer1.ZoomMode = ZoomMode.FitWidth;
        }

Another way to zoom in or out of Word document is enter a desired percentage in TextBox.

Code for TextBox:

      private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (Keys.Enter == e.KeyCode)
            {
                int p;
                if (int.TryParse(this.toolStripTextBox1.Text, out p))
                {
                    this.docDocumentViewer1.ZoomTo(p);
                }
            }
        }

Run the program, you can get following windows application.

Zoom Word Document using Spire.DocViewer

Fit to Width:

Zoom Word Document using Spire.DocViewer

Zoom with 50 percentages:

Zoom Word Document using Spire.DocViewer

Add underline text in PDF in C#

2014-12-23 08:15:41 Written by support iceblue

Adding text into the PDF files is one of the most important requirements for developers. With the help of Spire.PDF, developer can draw transform text, alignment text and rotate text in PDF files easily. This tutorial will show you how to add underline text in C#.

By using the method canvas.drawstring offered by Spire.PDF, developers can set the position, font, brush and style for the adding texts. With the PdfFontStyle, developers can set the style to underline, bold, italic, regular and strikeout. Here comes to the code snippet of how to add underline text in PDF.

Step 1: Create a new PDF document.

PdfDocument pdf = new PdfDocument();

Step 2: Add a new page to the PDF file.

PdfPageBase page = pdf.Pages.Add();

Step 3: Create a true type font with size 20f, underline style.

PdfTrueTypeFont font = new PdfTrueTypeFont(@"C:\WINDOWS\Fonts\CONSOLA.TTF", 20f, PdfFontStyle.Underline);

Step 4: Create a blue brush.

PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);

Step 5: Draw the text string at the specified location with the specified Brush and Font objects.

page.Canvas.DrawString("Hello E-iceblue Support Team", font, brush, new PointF(10, 10));

Step 6: Save the PDF file.

pdf.SaveToFile("Result.pdf", FileFormat.PDF);

Effective screenshot:

How to add underline text in PDF in C#

Full codes:

using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;


namespace AddUnderlinetext
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument pdf = new PdfDocument();
            PdfPageBase page = pdf.Pages.Add();
            PdfTrueTypeFont font = new PdfTrueTypeFont(@"C:\WINDOWS\Fonts\CONSOLA.TTF", 20f, PdfFontStyle.Underline);
            PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
            page.Canvas.DrawString("Hello E-iceblue Support Team", font, brush, new PointF(10, 10));
            pdf.SaveToFile("Result.pdf", FileFormat.PDF);
        }
    }
}

Built-in table styles are predefined formatting options that can be quickly applied to any table, greatly enhancing its appearance and readability. As same as MS PowerPoint, Spire.Presentation provides such a feature to give your table a professional look by applying a certain built-in table style. This article presents how this purpose can be achieved using Spire.Presentation with C#, VB.NET.

As we can see from below picture, plain tale is not that attractive before applying any style.

How to Apply Built-in Style to PowerPoint Table in C#, VB.NET

Code Snippet for Applying Table Style:

Step 1: Create an instance of presentation and load the test file.

Presentation ppt = new Presentation("test.pptx", FileFormat.Pptx2010);

Step 2: Get the table from presentation slide.

ITable table = ppt.Slides[0].Shapes[1] as ITable;

Step 3: Choose one table style from TableStylePreset and apply it to selected table.

table.StylePreset = TableStylePreset.MediumStyle2Accent2;

Step 4: Save the file.

ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);

Output:

How to Apply Built-in Style to PowerPoint Table in C#, VB.NET

Full Code:

[C#]
using Spire.Presentation;

namespace Apply_Built_in_Style
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation ppt = new Presentation("test.pptx", FileFormat.Pptx2010);
            ITable table = ppt.Slides[0].Shapes[1] as ITable;
            table.StylePreset = TableStylePreset.MediumStyle2Accent2;
            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);

        }

    }
}
[VB.NET]
Imports Spire.Presentation

Namespace Apply_Built_in_Style

	Class Program

		Private Shared Sub Main(args As String())
			Dim ppt As New Presentation("test.pptx", FileFormat.Pptx2010)
			Dim table As ITable = TryCast(ppt.Slides(0).Shapes(1), ITable)
			table.StylePreset = TableStylePreset.MediumStyle2Accent2
			ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010)

		End Sub

	End Class
End Namespace

We have already shown you how to use the method ListObjects to filter the data and format it as a table. This article will focus on demonstrate how to remove the auto filters with the method AutoFilters offered by Spire.XLS. Developer can also use the method sheet.AutoFilters.Range to create the auto filters.

Step 1: Create an excel document and load the Excel with auto filers from file.

Workbook workbook = new Workbook();
workbook.LoadFromFile("Filter.xlsx ");

Step 2: Gets the first worksheet in the Excel file.

Worksheet sheet = workbook.Worksheets[0];

Step 3: Remove the auto filters.

sheet.AutoFilters.Clear();

Step 4: Save the document to file.

workbook.SaveToFile("Result.xlsx", ExcelVersion.Version2010);

Screenshot for the Excel files with auto filters:

How to remove auto filters in Excel

The effective screenshot of removing the auto filters:

How to remove auto filters in Excel

Full codes:

using Spire.Xls;
namespace RemoveAutoFilter
{
    class Program
    {

      static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Filter.xlsx");

            Worksheet sheet = workbook.Worksheets[0];
            sheet.AutoFilters.Clear();

            workbook.SaveToFile("result.xlsx", ExcelVersion.Version2010);
        }


        }
    }

This article has demonstrated how to create a Windows Forms Application to open and close Word file using Spire.DocViewer. Now, we are adding a print button to Form1 to fulfill the print feature for this Word document viewer.

Detailed Steps

Step 1: Add another button to Form1, and set the following properties for it in the Properties Window:

  • Name: btnPrint
  • DisplayStyle: Image
  • Image: Print.Properties.Resources.Print

Step 2: Double click the button to write code. In this button code, we firstly instantiate an object of System.Windows.Forms.PrintDialog and set some of its relative properties. Call ShowDialog method to make the print dialog visible.

    private void btnPrint_Click(object sender, EventArgs e)
        {
            //Show a Print Dialog
            PrintDialog dialog = new PrintDialog();
            dialog.AllowCurrentPage = true;
            dialog.AllowSomePages = true;
            dialog.UseEXDialog = true;
            DialogResult result = dialog.ShowDialog();
            //...
         }

Step 3: Set print parameters of DocDocumentViewer.PrintDialog and print the document.

            //...
                 if (result == DialogResult.OK)
            {
                try
                {
                    //Set print parameters.
                    this.docDocumentViewer1.PrintDialog = dialog;
                    //Gets the PrintDocument.
                    dialog.Document = docDocumentViewer1.PrintDocument;
                    dialog.Document.Print();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

Run the program, open an existing Word file and click 'Print' button, you'll get a dialog as below:

How to Print Word Document using Spire.DocViewer

Auto Filter is the most convenient way to select the data we want from a large amount of the data in an excel data table. With the help of Spire.XLS for .NET, developers can use the method ListObjects to filter the data and format it as a table. This article will focus on show you how to add table with filter in Excel.

Step 1: Create an excel document and load the Excel from file:

Workbook workbook = new Workbook();
workbook.LoadFromFile("DataTable.xlsx");

Step 2: Gets the first worksheet in the Excel file

Worksheet sheet = workbook.Worksheets[0];

Step 3: Create a List Object named in Table

sheet.ListObjects.Create("Table", sheet.Range[1, 1, sheet.LastRow, sheet.LastColumn]);

Step 4: Set the BuiltInTableStyle for List object.

sheet.ListObjects[0].BuiltInTableStyle = TableBuiltInStyles.TableStyleLight9;

Step 5: Save the document to file.

workbook.SaveToFile("Filter.xlsx", ExcelVersion.Version2010);

Effective screenshot after the date has been auto filtered:

How to filter data in Excel in C#

Full codes:

namespace Excelfilter
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("DataTable.xlsx");

            Worksheet sheet = workbook.Worksheets[0];

            sheet.ListObjects.Create("Table", sheet.Range[1, 1, sheet.LastRow, sheet.LastColumn]);

            sheet.ListObjects[0].BuiltInTableStyle = TableBuiltInStyles.TableStyleLight9;

            workbook.SaveToFile("Filter.xlsx", ExcelVersion.Version2010);
        }
    }
}

This article introduces how to export Word file pages as png images in Windows Forms Application using Spire.DocViewer. Let’s see detailed steps.

First, download Spire.DocViewer, add DocViewer Control to VS Toolbox.

Export Word File as Image using Spire.DocViewer

Then create a Windows Forms Application, design your Form1 as below.

  • Add 'Open Document' button to open an existing Word file.
  • Add two check boxes and two text boxes, which are designed for choosing a range of pages to do the conversion.
  • Add 'Save to Image' button to save selected pages as images.
  • Drag 'DocDocumentViewer Control' into Form1, which is used to display Word document.

Export Word File as Image using Spire.DocViewer

Code Snippet:

Step 1: Create an OpenFileDialog to select the correct file type that you want to load. If you try to open with another file type except .doc and .docx, error message 'Cannot detect current file type' will appear.

       private void btnOpen_Click(object sender, EventArgs e)
        {
            //Open a Doc Document
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter="Word97-2003 files(*.doc)|*.doc|Word2007-2010 files (*.docx)|*.docx|All files (*.*)|*.*";
            dialog.Title="Select a DOC file";
            dialog.Multiselect=false;
            dialog.InitialDirectory=System.IO.Path.GetFullPath(@"..\..\..\..\..\..\Data");           
           
            DialogResult result = dialog.ShowDialog();
            if (result==DialogResult.OK)
            {
                try
                {
                    // Load doc document from file.
                    this.docDocumentViewer1.LoadFromFile(dialog.FileName);
                    this.textBox2.Text = this.docDocumentViewer1.PageCount.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

Step 2: The code behind 'Save to Image' button enables users to export the specified pages (from textbox1 to textBox2) as Bitmapsource, then convert Bitmapsource to images.

        private void btnSaveImage_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            bitMap.Clear();
            try
            {
                if (ckbFrom.Checked && ckbTo.Checked)
                {
                    try
                    {
                        int startIndex = 0;
                        int.TryParse(textBox1.Text, out startIndex);
                        m_CurrentPageNum = startIndex;
                        int endIndex = 0;
                        int.TryParse(textBox2.Text, out endIndex);

                        // Exports the specified pages as Images
                        Image[] bitmapsource = this.docDocumentViewer1.SaveImage((ushort)(startIndex), (ushort)(endIndex));
                        SaveImageToFile(bitmapsource);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (ckbFrom.Checked && !ckbTo.Checked)
                {
                    try
                    {
                        int currepageIndex = 0;
                        int.TryParse(textBox1.Text, out currepageIndex);
                        m_CurrentPageNum = currepageIndex;
                        //Saves the specified page as Image
                        Image bitmapsource = this.docDocumentViewer1.SaveImage((ushort)(currepageIndex));
                        SaveImageToFile(new Image[] { bitmapsource });
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch { };
            this.Enabled = true;
        }

Step 3: In step 2, SaveImageToFile() has been invoked. This part creates two customized methods SaveImageToFile() and WriteImageFile(), which is meant to save Bitmapsource as png images with the page index as its file name.

       private void SaveImageToFile(Image[] bitmpaSource)
        {
            int startIndex = 1;
            int.TryParse(textBox1.Text, out startIndex);
            foreach (Image bitmap in bitmpaSource)
            {
                WriteImageFile(bitmap, startIndex);
                startIndex++;
            }
        }

        // BitmapSource Write to File
        private void WriteImageFile(Image bitMapImg, int currentPageIndex)
        {
            try
            {
                if (bitMapImg != null)
                {
                    string FullfileName = currentPageIndex.ToString() + ".png";

                    bitMapImg.Save(FullfileName, System.Drawing.Imaging.ImageFormat.Png);
                    bitMap.Add(FullfileName, bitMapImg);
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine(ex.Message + ex.Source);
#endif
            }
        }

Debug the code, you'll get a Windows application as designed. Here, I open a sample Word file and select page 1 to page 11, selected pages will be saved as images in bin folder by clicking 'Save to Image'.

Export Word File as Image using Spire.DocViewer

This article presents how to create a Windows Forms Application to open a Word file and convert it to PDF format using Spire.DocViewer. In fact, conversion from Word to HTML, RTF, DOC, DOCX are also supported with this DocViewer control. You can try almost the same way demonstrated in the following section to convert Word to any other format.

First of all, download Spire.DocViewer, add DocViewer Control to VS Toolbox.

Save Word File to PDF using Spire.DocViewer

Then create a Windows Forms application, design your Form1 as below.

  • Add 'Open' button to open a file from existing Word document.
  • Add 'Close' button to shut down the open file.
  • Add 'ToPDF' button to save Word file as PDF format.
  • Drag 'DocDocumentViewer Control' into Form1, which is used to display Word document.

Save Word File to PDF using Spire.DocViewer

Code Snippet:

Step 1: Initialize components in Form1.

       public Form1()
       {
          InitializeComponent(); 
       }

Step 2: Create an OpenFileDialog to select the correct file type that we want to load, otherwise error message 'Cannot detect current file type' will appear.

       private void bntOpen_Click(object sender, EventArgs e)
        {
            //Open a doc document          
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "Word97-2003 files(*.doc)|*.doc|Word2007-2010 files (*.docx)|*.docx|All files (*.*)|*.*";
            dialog.Title = "Select a DOC file";
            dialog.Multiselect = false;
            dialog.InitialDirectory = System.IO.Path.GetFullPath(@"..\..\..\..\..\..\Data");

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    this.docDocumentViewer1.LoadFromFile(dialog.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

Step 3: In the 'ToPDF' button click event, create a SaveFileDialog, set filter as PDF type, then call DocDocumentViewer.SaveAs() method to save Word as PDF with customized file name.

       private void btnSaveToPdf_Click(object sender, EventArgs e)
        {
            SaveFileDialog savefile = new SaveFileDialog();
            savefile.Filter = "Pdf Document(*.pdf)|*.pdf";
            savefile.Title = "Save";

            DialogResult result = savefile.ShowDialog();
            if (result == DialogResult.OK)
            {
                try
                {
                    //Save PDF documetns
                    this.docDocumentViewer1.SaveAs(savefile.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

Step 4: Close the open file.

        private void btnClose_Click(object sender, EventArgs e)
        {
            //Close current doc document.
            this.docDocumentViewer1.CloseDocument();
        }

After debugging the code, I opened a sample Word file. The save dialog box will pop up by clicking 'ToPDF' button.

Save Word File to PDF using Spire.DocViewer

This article presents how to create a Windows Forms application to open and close your Word files using Spire.DocViewer component. Detailed steps would be as follows:

First of all, download Spire.DocViewer, add DocViewer Control to VS Toolbox.

How to Open and Close Word Files using Spire.DocViewer

Then create a Windows Forms application, design your Form1 as below.

  • Add 'Open from file' button to open a file from existing Word document.
  • Add 'Open from stream' button to load a Word file from steam.
  • Add 'Close' button to shut down the open file.
  • Drag 'DocDocumentViewer Control' into Form1, which is used to display Word document.

How to Open and Close Word Files using Spire.DocViewer

Code Snippet:

Step 1: Initialize components in Form1.

        System.IO.FileStream stream;
        public Form1()
        {
            InitializeComponent();
          
        }

Step 2: Create an OpenFileDialog to select the correct file type that we want to load, otherwise error message 'Cannot detect current file type' will occur.

private void btnOpen_Click(object sender, EventArgs e)
        {
            //open a DOC document
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "Word97-2003 files(*.doc)|*.doc|Word2007-2010 files (*.docx)|*.docx|All files (*.*)|*.*";
            dialog.Title = "Select a DOC file";
            dialog.Multiselect = false;
            dialog.InitialDirectory = System.IO.Path.GetFullPath(@"..\..\..\..\..\..\Data");

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    //Load DOC document from file.
                    this.docDocumentViewer1.LoadFromFile(dialog.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

Step 3: This button code enables users to open Word files from a stream in Xml or Microsoft Word format.

        private void btnOpenStream_Click(object sender, EventArgs e)
        {
            //open a doc document
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "Word97-2003 files(*.doc)|*.doc|Word2007-2010 files (*.docx)|*.docx|All files (*.*)|*.*";
            dialog.Title = "Select a DOC file";
            dialog.Multiselect = false;
            dialog.InitialDirectory = System.IO.Path.GetFullPath(@"..\..\..\..\..\..\Data");
            
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    string docFile = dialog.FileName;
                    stream = new System.IO.FileStream(docFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
                    if (stream != null)
                    {
                        //Load doc document from stream.
                        this.docDocumentViewer1.LoadFromStream(stream, Spire.Doc.FileFormat.Auto);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

Step 4: Close the open file.

        private void btnClose_Click(object sender, EventArgs e)
        {
            //Close current doc document.
            this.docDocumentViewer1.CloseDocument();
        }

After running the code, I opened a test file with this Windows application. Here is the screenshot of effect:

How to Open and Close Word Files using Spire.DocViewer

page 51