When you want to use multiple themes in one presentation, you’ll need multiple slide masters. In this article, you will learn how create additional slide masters and apply them to different slides, by using Spire.Presentation with C# and VB.NET.

Step 1: Create a PowerPoint document and insert four slides to it. There are five slides in total including the default slide.

Presentation ppt = new Presentation();
for (int i = 0; i < 4; i++)
{
    ppt.Slides.Append();
}

Step 2: Get the first default slide master.

IMasterSlide first_master = ppt.Masters[0];

Step 3: Append another slide master.

ppt.Masters.AppendSlide(first_master);
IMasterSlide second_master = ppt.Masters[1];

Step 4: Set different background image for the two slide masters.

string pic1 = @"C:\Users\Administrator\Desktop\image-1.png";
string pic2 = @"C:\Users\Administrator\Desktop\image-2.png";
RectangleF rect = new RectangleF(0, 0, ppt.SlideSize.Size.Width, ppt.SlideSize.Size.Height);
first_master.SlideBackground.Fill.FillType = FillFormatType.Picture;         
IEmbedImage image1 = first_master.Shapes.AppendEmbedImage(ShapeType.Rectangle, pic1, rect);
first_master.SlideBackground.Fill.PictureFill.Picture.EmbedImage = image1 as IImageData;
second_master.SlideBackground.Fill.FillType = FillFormatType.Picture;
IEmbedImage image2 = second_master.Shapes.AppendEmbedImage(ShapeType.Rectangle, pic2, rect);
second_master.SlideBackground.Fill.PictureFill.Picture.EmbedImage = image2 as IImageData;

Step 5: Apply the first master with layout to the first slide.

ppt.Slides[0].Layout = first_master.Layouts[1];

Step 6: Apply the second master with layout to other slides.

for (int i = 1; i < ppt.Slides.Count; i++)
{
    ppt.Slides[i].Layout = second_master.Layouts[8];
}

Step 7: Save the file.

ppt.SaveToFile("result.pptx", FileFormat.Pptx2013);

Output:

Create Multiple Slide Maters and Apply Them to Individual Slides in C#, VB.NET

Full Code:

[C#]
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace  CreateMultipleMaster
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.SlideSize.Type = SlideSizeType.Screen16x9;
            for (int i = 0; i < 4; i++)
            {
                ppt.Slides.Append();
            }

            IMasterSlide first_master = ppt.Masters[0];
            ppt.Masters.AppendSlide(first_master);
            IMasterSlide second_master = ppt.Masters[1];

            string pic1 = @"C:\Users\Administrator\Desktop\image-1.png";
            string pic2 = @"C:\Users\Administrator\Desktop\image-2.png";
            RectangleF rect = new RectangleF(0, 0, ppt.SlideSize.Size.Width, ppt.SlideSize.Size.Height);
            first_master.SlideBackground.Fill.FillType = FillFormatType.Picture;
            IEmbedImage image1 = first_master.Shapes.AppendEmbedImage(ShapeType.Rectangle, pic1, rect);
            first_master.SlideBackground.Fill.PictureFill.Picture.EmbedImage = image1 as IImageData;
            second_master.SlideBackground.Fill.FillType = FillFormatType.Picture;
            IEmbedImage image2 = second_master.Shapes.AppendEmbedImage(ShapeType.Rectangle, pic2, rect);
            second_master.SlideBackground.Fill.PictureFill.Picture.EmbedImage = image2 as IImageData;

            ppt.Slides[0].Layout = first_master.Layouts[1];
            for (int i = 1; i < ppt.Slides.Count; i++)
            {
                ppt.Slides[i].Layout = second_master.Layouts[8];
            }
            ppt.SaveToFile("result.pptx", FileFormat.Pptx2013);

            }
        }
    }
[VB.NET]
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System.Drawing
Namespace CreateMultipleMaster
	Class Program
		Private Shared Sub Main(args As String())
			Dim ppt As New Presentation()
			ppt.SlideSize.Type = SlideSizeType.Screen16x9
			For i As Integer = 0 To 3
				ppt.Slides.Append()
			Next

			Dim first_master As IMasterSlide = ppt.Masters(0)
			ppt.Masters.AppendSlide(first_master)
			Dim second_master As IMasterSlide = ppt.Masters(1)

			Dim pic1 As String = "C:\Users\Administrator\Desktop\image-1.png"
			Dim pic2 As String = "C:\Users\Administrator\Desktop\image-2.png"
			Dim rect As New RectangleF(0, 0, ppt.SlideSize.Size.Width, ppt.SlideSize.Size.Height)
			first_master.SlideBackground.Fill.FillType = FillFormatType.Picture
			Dim image1 As IEmbedImage = first_master.Shapes.AppendEmbedImage(ShapeType.Rectangle, pic1, rect)
			first_master.SlideBackground.Fill.PictureFill.Picture.EmbedImage = TryCast(image1, IImageData)
			second_master.SlideBackground.Fill.FillType = FillFormatType.Picture
			Dim image2 As IEmbedImage = second_master.Shapes.AppendEmbedImage(ShapeType.Rectangle, pic2, rect)
			second_master.SlideBackground.Fill.PictureFill.Picture.EmbedImage = TryCast(image2, IImageData)

			ppt.Slides(0).Layout = first_master.Layouts(1)
			For i As Integer = 1 To ppt.Slides.Count - 1
				ppt.Slides(i).Layout = second_master.Layouts(8)
			Next
			ppt.SaveToFile("result.pptx", FileFormat.Pptx2013)

		End Sub
	End Class
End Namespace

Every PowerPoint presentation has a slide master which contains all the styles for your slides. You can quickly change the look of your entire presentation by selecting the slide master, and then adopting a theme, adding a background picture or changing the color scheme.

In this article, you will learn how to access and customize the slide master in an existing presentation.

Source File:

Apply a Slide Master to a Presentation in 

C#, VB.NET

Detail steps:

Step 1: Load the source file.

Presentation ppt = new Presentation();
ppt.LoadFromFile(@"sample.pptx");

Step 2: Get the first slide master from the presentation.

IMasterSlide masterSlide = ppt.Masters[0];

Step 3: Customize the background of the slide master.

string backgroundPic = "background.png";
RectangleF rect = new RectangleF(0, 0, ppt.SlideSize.Size.Width, ppt.SlideSize.Size.Height);
masterSlide.SlideBackground.Fill.FillType = FillFormatType.Picture;
IEmbedImage image = masterSlide.Shapes.AppendEmbedImage(ShapeType.Rectangle, backgroundPic, rect);
masterSlide.SlideBackground.Fill.PictureFill.Picture.EmbedImage = image as IImageData;

Step 4: Change the color scheme.

masterSlide.Theme.ColorScheme.Accent1.Color = Color.Red;
masterSlide.Theme.ColorScheme.Accent2.Color = Color.RosyBrown;
masterSlide.Theme.ColorScheme.Accent3.Color = Color.Ivory;
masterSlide.Theme.ColorScheme.Accent4.Color = Color.Lavender;
masterSlide.Theme.ColorScheme.Accent5.Color = Color.Black;

Step 5: Add an image to the slide master. If you want, you can add any other document elements to slide master so that they can display on each slide.

string logo = "logo.png";
IEmbedImage imageShape = masterSlide.Shapes.AppendEmbedImage(ShapeType.Rectangle, logo, new RectangleF(40, 40, 240, 65));
imageShape.Line.FillFormat.FillType = FillFormatType.None;

Step 6: Save the document.

ppt.SaveToFile("result.pptx", FileFormat.Pptx2013);

Result:

Apply a Slide Master to a Presentation in C#, VB.NET

Full code:

[C#]
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace ApplySlideMaster 
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile(@"sample.pptx");

            IMasterSlide masterSlide = ppt.Masters[0];
            string backgroundPic = "background.png";
            string logo = "logo.png";
            RectangleF rect = new RectangleF(0, 0, ppt.SlideSize.Size.Width, ppt.SlideSize.Size.Height);
            masterSlide.SlideBackground.Fill.FillType = FillFormatType.Picture;
            IEmbedImage image = masterSlide.Shapes.AppendEmbedImage(ShapeType.Rectangle, backgroundPic, rect);
            masterSlide.SlideBackground.Fill.PictureFill.Picture.EmbedImage = image as IImageData;
            masterSlide.Theme.ColorScheme.Accent1.Color = Color.Red;
            masterSlide.Theme.ColorScheme.Accent2.Color = Color.RosyBrown;
            masterSlide.Theme.ColorScheme.Accent3.Color = Color.Ivory;
            masterSlide.Theme.ColorScheme.Accent4.Color = Color.Lavender;
            masterSlide.Theme.ColorScheme.Accent5.Color = Color.Black;
            IEmbedImage imageShape = masterSlide.Shapes.AppendEmbedImage
            (ShapeType.Rectangle, logo, new RectangleF(40, 40, 240, 65));
            imageShape.Line.FillFormat.FillType = FillFormatType.None;

            ppt.SaveToFile("result.pptx", FileFormat.Pptx2013);

            }
        }
    }
[VB.NET]
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System.Drawing
Namespace ApplySlideMaster
	Class Program
		Private Shared Sub Main(args As String())
			Dim ppt As New Presentation()
			ppt.LoadFromFile("sample.pptx")

			Dim masterSlide As IMasterSlide = ppt.Masters(0)
			Dim backgroundPic As String = "background.png"
			Dim logo As String = "logo.png"
			Dim rect As New RectangleF(0, 0, ppt.SlideSize.Size.Width, ppt.SlideSize.Size.Height)
			masterSlide.SlideBackground.Fill.FillType = FillFormatType.Picture
			Dim image As IEmbedImage = masterSlide.Shapes.AppendEmbedImage(ShapeType.Rectangle, backgroundPic, rect)
			masterSlide.SlideBackground.Fill.PictureFill.Picture.EmbedImage = TryCast(image, IImageData)
			masterSlide.Theme.ColorScheme.Accent1.Color = Color.Red
			masterSlide.Theme.ColorScheme.Accent2.Color = Color.RosyBrown
			masterSlide.Theme.ColorScheme.Accent3.Color = Color.Ivory
			masterSlide.Theme.ColorScheme.Accent4.Color = Color.Lavender
			masterSlide.Theme.ColorScheme.Accent5.Color = Color.Black
			Dim imageShape As IEmbedImage = masterSlide.Shapes.AppendEmbedImage(ShapeType.Rectangle, logo, New RectangleF(40, 40, 240, 65))
			imageShape.Line.FillFormat.FillType = FillFormatType.None

			ppt.SaveToFile("result.pptx", FileFormat.Pptx2013)

		End Sub
	End Class
End Namespace

Spire.Presentation supports to align text vertically in a table cell on the presentation slides. In this article, we will show you how to use C# to align the text in table cell and set the text direction. Firstly, view the screenshot on Microsoft PowerPoint of the vertical alignment and the text direction:

Vertically align the text in 

table cell

Detail steps:

Step 1: Create a new PowerPoint document and load the sample document from file.

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

Step 2: Get the table shape from the first presentation slide.

ITable table = null;
foreach (IShape shape in ppt.Slides[0].Shapes)
{
    if (shape is ITable)
    {
        table = (ITable)shape;

Step 3: Aligning the text vertically and set the text direction.

table[i, 0].TextAnchorType = TextAnchorType.Center;          
table[i, 0].VerticalTextType = VerticalTextType.Vertical270;

table[i, 1].TextAnchorType = TextAnchorType.Center;
table[i, 1].VerticalTextType = VerticalTextType.Horizontal;

table[i, 2].TextAnchorType = TextAnchorType.Center;
table[i, 2].VerticalTextType = VerticalTextType.Vertical;

Step 4: Save the document to file.

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

Effective screenshot after set the vertical alignment and the text direction:

Vertically align the text in 

table cell

Full codes of vertical align the text and set the text direction.:

using Spire.Presentation;

namespace AlignText
{

    class Program
    {
        static void Main(string[] args)
        {

            Presentation ppt = new Presentation();

            ppt.LoadFromFile("Sample1.pptx", FileFormat.Pptx2010);

            ITable table = null;
            foreach (IShape shape in ppt.Slides[0].Shapes)
            {
                if (shape is ITable)
                {
                    table = (ITable)shape;

                    for (int i = 0; i < table.ColumnsList.Count; i++)
                    {
                        table[i, 0].TextAnchorType = TextAnchorType.Center;
                        table[i, 0].VerticalTextType = VerticalTextType.Vertical270;


                        table[i, 1].TextAnchorType = TextAnchorType.Center;
                        table[i, 1].VerticalTextType = VerticalTextType.Horizontal;

                        table[i, 2].TextAnchorType = TextAnchorType.Center;
                        table[i, 2].VerticalTextType = VerticalTextType.Vertical;

                    }
                }
            }

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

        }
    }
}

With Spire.Presentation, we can programmatically set the Alternative Text for PowerPoint shapes along with get the Alternative Text of PowerPoint shapes. This article demonstrates how we can use Spire.Presentation to accomplish this function.

Detail steps:

Step 1: Instantiate a Presentation object and load the PowerPoint file.

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

Step 2: Get the first slide.

ISlide slide = ppt.Slides[0];

Step 3: Set or get the alternative text of the first Shape in the slide.

//Set the alternative text (title and description)
slide.Shapes[0].AlternativeTitle = "Rectangle";
slide.Shapes[0].AlternativeText = "This is a Rectangle";

//Get the alternative text (title and description)
//string title = slide.Shapes[0].AlternativeTitle;
//string description = slide.Shapes[0].AlternativeText;

Step 4: Save the file.

ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);

Screenshot after setting alternative text:

Set and Get Alternative Text 

(Title and Description) of PowerPoint Shapes in C#

Full code:

using Spire.Presentation;

namespace Set_and_Get_Alternative_Text_of_Shape
{
    class Program
    {
        static void Main(string[] args)
        {
            //Instantiate a Presentation object
            Presentation ppt = new Presentation();
            //Load the PowerPoint file
            ppt.LoadFromFile("Input.pptx");

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

            //Set the alternative text (title and description)
            slide.Shapes[0].AlternativeTitle = "Rectangle";
            slide.Shapes[0].AlternativeText = "This is a Rectangle";

            //Get the alternative text (title and description)
            //string title = slide.Shapes[0].AlternativeTitle;
            //string description = slide.Shapes[0].AlternativeText;

            //Save the file
            ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);
        }
    }
}

Bookmarks are a great way to specify important locations on a Word document. Spire.Doc supports to access the bookmarks within the document and insert objects such as text, image and table at the bookmark location. This article will show you how to access a specific bookmark and replace the current bookmark content with a table.

Step 1: Load a template Word document.

Document doc = new Document();
doc.LoadFromFile(@"C:\Users\Administrator\Desktop\employee.docx");

Step 2: Create a Table object.

Table table = new Table(doc,true);

Step 3: Fill the table with sample data.

DataTable dt = new DataTable();
dt.Columns.Add("id", typeof(string));
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("job", typeof(string));
dt.Columns.Add("email", typeof(string));
dt.Columns.Add("salary", typeof(string));
dt.Rows.Add(new string[] { "Emp_ID", "Name", "Job", "E-mail", "Salary" });
dt.Rows.Add(new string[] { "0241","Andrews", "Engineer", "andrews@outlook.com" ,"3.8K"});
dt.Rows.Add(new string[] { "0242","White", "Manager", "white@outlook.com","4.2K" });
dt.Rows.Add(new string[] { "0243","Martin", "Secretary", "martin@gmail.com", "3.5K" });
table.ResetCells(dt.Rows.Count, dt.Columns.Count);          
for (int i = 0; i < dt.Rows.Count; i++)
{
    for (int j = 0; j < dt.Columns.Count; j++)
    {
        table.Rows[i].Cells[j].AddParagraph().AppendText(dt.Rows[i][j].ToString());
    }
}

Step 4: Get the specific bookmark by its name.

BookmarksNavigator navigator = new BookmarksNavigator(doc);
navigator.MoveToBookmark("bookmark_employee");

Step 5: Create a TextBodyPart instance and add the table to it.

TextBodyPart part = new TextBodyPart(doc);
part.BodyItems.Add(table);

Step 6: Replace the current bookmark content with the TextBodyPart object.

navigator.ReplaceBookmarkContent(part);

Step 7: Save the file.

doc.SaveToFile("output.docx", FileFormat.Docx2013);

Result:

Replace Bookmark with a Table in Word Documents in C#, VB.NET

Full Code:

[C#]
using Spire.Doc;
using Spire.Doc.Documents;
using System.Data;
namespace ReplaceBookmark
{
    class Program
    {

        static void Main(string[] args)
        {

            Document doc = new Document();
            doc.LoadFromFile(@"C:\Users\Administrator\Desktop\employee.docx");

            Table table = new Table(doc, true);
            DataTable dt = new DataTable();
            dt.Columns.Add("id", typeof(string));
            dt.Columns.Add("name", typeof(string));
            dt.Columns.Add("job", typeof(string));
            dt.Columns.Add("email", typeof(string));
            dt.Columns.Add("salary", typeof(string));
            dt.Rows.Add(new string[] { "Emp_ID", "Name", "Job", "E-mail", "Salary" });
            dt.Rows.Add(new string[] { "0241", "Andrews", "Engineer", "andrews@outlook.com", "3.8K" });
            dt.Rows.Add(new string[] { "0242", "White", "Manager", "white@outlook.com", "4.2K" });
            dt.Rows.Add(new string[] { "0243", "Martin", "Secretary", "martin@gmail.com", "3.5K" });
            table.ResetCells(dt.Rows.Count, dt.Columns.Count);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    table.Rows[i].Cells[j].AddParagraph().AppendText(dt.Rows[i][j].ToString());
                }
            }

            BookmarksNavigator navigator = new BookmarksNavigator(doc);
            navigator.MoveToBookmark("bookmark_employee");
            TextBodyPart part = new TextBodyPart(doc);
            part.BodyItems.Add(table);
            navigator.ReplaceBookmarkContent(part);
            doc.SaveToFile("output.docx", FileFormat.Docx2013);
            System.Diagnostics.Process.Start("output.docx"); 

        }
    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports System.Data
Namespace ReplaceBookmark
	Class Program

		Private Shared Sub Main(args As String())

			Dim doc As New Document()
			doc.LoadFromFile("C:\Users\Administrator\Desktop\employee.docx")

			Dim table As New Table(doc, True)
			Dim dt As New DataTable()
			dt.Columns.Add("id", GetType(String))
			dt.Columns.Add("name", GetType(String))
			dt.Columns.Add("job", GetType(String))
			dt.Columns.Add("email", GetType(String))
			dt.Columns.Add("salary", GetType(String))
			dt.Rows.Add(New String() {"Emp_ID", "Name", "Job", "E-mail", "Salary"})
			dt.Rows.Add(New String() {"0241", "Andrews", "Engineer", "andrews@outlook.com", "3.8K"})
			dt.Rows.Add(New String() {"0242", "White", "Manager", "white@outlook.com", "4.2K"})
			dt.Rows.Add(New String() {"0243", "Martin", "Secretary", "martin@gmail.com", "3.5K"})
			table.ResetCells(dt.Rows.Count, dt.Columns.Count)
			For i As Integer = 0 To dt.Rows.Count - 1
				For j As Integer = 0 To dt.Columns.Count - 1
					table.Rows(i).Cells(j).AddParagraph().AppendText(dt.Rows(i)(j).ToString())
				Next
			Next

			Dim navigator As New BookmarksNavigator(doc)
			navigator.MoveToBookmark("bookmark_employee")
			Dim part As New TextBodyPart(doc)
			part.BodyItems.Add(table)
			navigator.ReplaceBookmarkContent(part)
			doc.SaveToFile("output.docx", FileFormat.Docx2013)
			System.Diagnostics.Process.Start("output.docx")

		End Sub
	End Class
End Namespace

If you want to find values that are higher or lower than the average, you don't have to calculate the average, and then check those that are higher or lower. Using conditional formatting in Excel, you can automatically highlight those numbers. In this article, you will learn how to highlight values above average or below average with conditional formatting, by using Spire.XLS for .NET.

Install Spire.XLS for .NET

To begin with, you need to add the DLL files included in the Spire.XLS 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.XLS

Highlight Values Above or Below Average in Excel

Below are the steps to highlight values above or below average in Excel using Spire.XLS for .NET.

  • Create a Workbook object.
  • Load an Excel file using Workbook.LoadFromFile() method.
  • Get a specific worksheet from the workbook through Workbook.Worsheets[index] property.
  • Add a conditional formatting to the worksheet using Worksheet.ConditionalFormats.Add() method and return an object of XlsConditionalFormats class.
  • Set the cell range where the conditional formatting will be applied using XlsConditionalFormats.AddRange() method.
  • Add an average condition using XlsConditionalFormats.AddAverageCondition() method, specify the average type to above and change the background color of the cells that meet the condition to yellow.
  • Add another average condition to change the background color of the below average values to dark gray.
  • Save the workbook to an Excel file using Workbook.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Xls;
using Spire.Xls.Core;
using Spire.Xls.Core.Spreadsheet.Collections;
using System.Drawing;

namespace HighlightValuesAboveAndBelowAverage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook object
            Workbook workbook = new Workbook();

            //Load an Excel file
            workbook.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.xlsx");

            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Add a conditional format to the worksheet
            XlsConditionalFormats format = sheet.ConditionalFormats.Add();

            //Set the range where the conditional format will be applied
            format.AddRange(sheet.Range["F2:F14"]);

            //Add a condition to highlight the top 2 ranked values
            IConditionalFormat condition1 = format.AddAverageCondition(AverageType.Above);
            condition1.BackColor = Color.Yellow;

            //Add a condition to highlight the bottom 2 ranked values
            IConditionalFormat condition2 = format.AddAverageCondition(AverageType.Below);
            condition2.BackColor = Color.DarkGray;

            //Get the count of values below average
            sheet.Range["F17"].Formula = "=COUNTIF(F2:F14,\"<\"&AVERAGE(F2:F14))";

            //Get the count of values above average
            sheet.Range["F18"].Formula = "=COUNTIF(F2:F14,\">\"&AVERAGE(F2:F14))";

            //Save the workbook to an Excel file
            workbook.SaveToFile("HighlightValues.xlsx", ExcelVersion.Version2016);
        }
    }
}

C#/VB.NET: Highlight Values Above or Below Average in Excel

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.

Spire.Presentation supports to set the default position (e.g. Outside End, Center, Inside End, Inside base etc.) of data labels through ChartDataLabel.Position property, it also supports to set custom position of data labels using "ChartDataLabel.X" and "ChartDataLabel.Y" properties. This article is going to elaborate how we can set default and custom position of data labels using Spire.Presentation.

Detail steps:

Step 1: Initialize a Presentation object and load the PowerPoint file.

Presentation ppt = new Presentation();
ppt.LoadFromFile(@"Input.pptx");

Step 2: Get the chart.

IChart chart = ppt.Slides[0].Shapes[0] as IChart;

Step 3: Add data label to the chart and set its id.

ChartDataLabel label1 = chart.Series[0].DataLabels.Add();            
label1.ID = 0;  

Step 4: Set the position of data label.

//Set the default position of data label. This position is relative to the data markers.
//label1.Position = ChartDataLabelPosition.OutsideEnd;

//Set custom position of data label. This position is relative to the default position. 
label1.X = 0.1f;
label1.Y = -0.1f;

Step 5: Set the properties of data label.

//Set label value visible
label1.LabelValueVisible = true;
//Set legend key invisible
label1.LegendKeyVisible = false;
//Set category name invisible
label1.CategoryNameVisible = false;
//Set series name invisible
label1.SeriesNameVisible = false;
//Set Percentage invisible
label1.PercentageVisible = false;

//Set border style and fill style of data label
label1.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
label1.Line.SolidFillColor.Color = Color.Blue;
label1.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
label1.Fill.SolidColor.Color = Color.Orange;

Step 6: Save the file.

ppt.SaveToFile(@"Output.pptx", FileFormat.Pptx2013);

Screenshot:

Default position (Outside End):

Set Position of Chart Data Labels in PowerPoint in C#

Custom position:

Set Position of Chart Data Labels in PowerPoint in C#

Full code:

using Spire.Presentation;
using Spire.Presentation.Charts;
using System.Drawing;

namespace Set_Position_of_Chart_Data_Label_in_PPT
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize a Presentation object
            Presentation ppt = new Presentation();
            //Load the PowerPoint file
            ppt.LoadFromFile(@"Input.pptx");

            //Get the chart
            IChart chart = ppt.Slides[0].Shapes[0] as IChart;

            //Add data label to chart and set its id
            ChartDataLabel label1 = chart.Series[0].DataLabels.Add();            
            label1.ID = 0;

            //Set the default position of data label. This position is relative to the data markers.
            //label1.Position = ChartDataLabelPosition.OutsideEnd;

            //Set custom position of data label. This position is relative to the default position.
            label1.X = 0.1f;
            label1.Y = -0.1f;

            //Set label value visible
            label1.LabelValueVisible = true;
            //Set legend key invisible
            label1.LegendKeyVisible = false;
            //Set category name invisible
            label1.CategoryNameVisible = false;
            //Set series name invisible
            label1.SeriesNameVisible = false;
            //Set Percentage invisible
            label1.PercentageVisible = false;

            //Set border style and fill style of data label
            label1.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            label1.Line.SolidFillColor.Color = Color.Blue;
            label1.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            label1.Fill.SolidColor.Color = Color.Orange;

            //Save the file                                   
            ppt.SaveToFile(@"Output.pptx", FileFormat.Pptx2013);
        }
    }
}

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:

Insert HTML with image into the Presentation slides in C#

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:

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

        }
    }
}
page 17