Knowledgebase (2300)
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):

Custom position:

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:

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