Knowledgebase (2417)
Children categories
We have already demonstrated how to use Spire.Presentation to insert HTML formatted text to PowerPoint slide. Now from Spire.Presentation 3.4.1, it supports to insert html (including text, image, audio and video) into presentation slides and each html tag will be added to the slide as a separate shape. The following code snippets demonstrate how to.
Step 1: Create an instance of Presentation class.
Presentation ppt = new Presentation();
Step 2: Get the shapes on the first slide.
ShapeList shapes = ppt.Slides[0].Shapes;
Step 3: Add contents to shape from HTML code, which includes text and image.
shapes.AddFromHtml("<html><div><p>First paragraph</p><p><img src='https://cdn.e-iceblue.com/Logo.jpg'/></p><p>Second paragraph </p></html>");
Step 4: Save the document to file.
ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);
Effective screenshot:

Full codes of how to insert HTML into the Presentation slides:
using Spire.Presentation;
using Spire.Presentation.Collections;
namespace InsertHTML
{
class Program
{
static void Main(string[] args)
{
Presentation ppt = new Presentation();
ShapeList shapes = ppt.Slides[0].Shapes;
shapes.AddFromHtml("First paragraph

Second paragraph
");
ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);
}
}
}
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:

Full Code:
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;
}
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:

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);
}
}
}