page 173

Using Spire.XLS, you're able to apply multiple fonts in a single cell in order to create rich-formatted text within the cell, you can also extract the formatted text from the cell(s) in an existing Excel document. The following code snippets will show you how to read rich text from an Excel cell in C# and VB.NET.

Step 1: Create a Workbook instance and load a sample Excel file.

Workbook wb = new Workbook();
wb.LoadFromFile(@"C:\Users\Administrator\Desktop\Sample.xlsx");

Step 2: Get the first worksheet.

Worksheet sheet= wb.Worksheets[0];

Step 3: Get the rtf text from the specified cell.

richTextBox1.Rtf = sheet.Range["B2"].RichText.RtfText;

Output:

Read Rich Text from an Excel Cell in C#, VB.NET

Full Code:

[C#]
private void btn_read_Click(object sender, EventArgs e)
{
    Workbook wb = new Workbook();
    wb.LoadFromFile(@"C:\Users\Administrator\Desktop\Sample.xlsx");
    Worksheet sheet= wb.Worksheets[0];
    richTextBox1.Rtf = sheet.Range["B2"].RichText.RtfText;
} 
[VB.NET]
Private  Sub btn_read_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim wb As Workbook =  New Workbook() 
    wb.LoadFromFile("C:\Users\Administrator\Desktop\Sample.xlsx")
    Dim sheet As Worksheet =  wb.Worksheets(0) 
    richTextBox1.Rtf = sheet.Range("B2").RichText.RtfText
End Sub

Hyperlinks can direct readers to a web page, a file, an E-mail address, or other place in the same PowerPoint file. A hyperlink can be added to a text, an image or a shape. In the previous article, we've illustrated how to add hyperlink to text, this article is going to demonstrate how to add hyperlink to an image in PowerPoint using Spire.Presentation.

Detail steps:

Step 1: Initialize an object of Presentation class and Load the PowerPoint file.

Presentation presentation = new Presentation();
presentation.LoadFromFile("Input.pptx");

Step 2: Get the first slide.

ISlide slide = presentation.Slides[0];

Step 3: Add image to slide.

RectangleF rect = new RectangleF(50, 300, 100, 100);
IEmbedImage image = slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, @"logo.png", rect);

Step 4: Add hyperlink to image.

ClickHyperlink hyperlink = new ClickHyperlink("https://www.e-iceblue.com");
image.Click = hyperlink;

Step 5: Save the file.

presentation.SaveToFile("ImageHyperLink.pptx", FileFormat.Pptx2010);

Screenshot:

Add Hyperlink to an Image in PowerPoint in C#

Full code:

using Spire.Presentation;
using System.Drawing;
namespace InitializeHyperlink
{

    class Program
    {

        static void Main(string[] args)
        {
            //Initialize an object of Presentation class
            Presentation presentation = new Presentation();
            //Load the PowerPoint file
            presentation.LoadFromFile("test.pptx");

            //Get the first slide
            ISlide slide = presentation.Slides[0];

            //Add image to slide
            RectangleF rect = new RectangleF(50, 300, 100, 100);
            IEmbedImage image = slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, @"logo.png", rect);

            //Add hyperlink to image
            ClickHyperlink hyperlink = new ClickHyperlink("https://www.e-iceblue.com");
            image.Click = hyperlink;

            //Save the file
            presentation.SaveToFile("ImageHyperLink.pptx", FileFormat.Pptx2010);

        }
    }
}

Watermarks can be added to Word documents to inform other people about the documents' ownership or status. Sometimes, you may want to get rid of an existing watermark in a Word document. This article will demonstrate how to remove watermarks from Word documents in C# and VB.NET using 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

Remove Text or Image Watermarks from Word Documents in C# and VB.NET

You can remove the watermark of a Word document by setting the Document.Watermark property as null.

The following steps show you how to remove the watermark from a Word document:

  • Initialize an instance of Document class.
  • Load a Word document using Document.LoadFromFile() method.
  • Remove the watermark from the document by setting the Document.Watermark property as null.
  • Save the result document using Document.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Doc;

namespace RemoveWatermark
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Document instance
            Document doc = new Document();
            //Load a Word document
            doc.LoadFromFile("Sample.docx");

            //Remove the watermark from the document
            doc.Watermark = null;

            //Save the result document
            doc.SaveToFile("RemoveWatermark.docx", FileFormat.Docx2013);
        }
    }
}

C#/VB.NET: Remove Text or Image Watermarks from Word Documents

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.

page 173