Interface IChartRichTextString
Represents rich text of the chart title.
Inherited Members
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public interface IChartRichTextString : IParentApplication, IOptimizedUpdate
Properties
FormattingRuns
Gets the formatting runs of the chart title. Read-only.
Declaration
ChartAlrunsRecord.TRuns[] FormattingRuns { get; }
Property Value
Type |
---|
Syncfusion.XlsIO.Parser.Biff_Records.Charts.ChartAlrunsRecord.TRuns[] |
Remarks
To know more about charts refer this link.
Examples
The following code illustrates use of FormattingRuns property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
//Gets the formatting runs of the chart title
int length = sheet.Charts[0].ChartTitleArea.RichText.FormattingRuns.Length;
if(length != 0)
{
//Your code here
}
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}
Text
Gets the chart title text. Read-only.
Declaration
string Text { get; }
Property Value
Type |
---|
System.String |
Remarks
To know more about charts refer this link.
Examples
The following code illustrates use of Text property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Student ID";
sheet.Range["B1"].Text = "Student Name";
sheet.Range["C1"].Text = "Mark(Out of 100)";
sheet.Range["A1:C1"].AutofitColumns();
sheet.Range["A2"].Number = 1;
sheet.Range["A3"].Number = 2;
sheet.Range["A4"].Number = 3;
sheet.Range["A5"].Number = 4;
sheet.Range["A6"].Number = 5;
sheet.Range["B2"].Text = "Andrew";
sheet.Range["B3"].Text = "Marson";
sheet.Range["B4"].Text = "Jack";
sheet.Range["B5"].Text = "Sam";
sheet.Range["B6"].Text = "Breto";
sheet.Range["C2"].Number = 77;
sheet.Range["C3"].Number = 45;
sheet.Range["C4"].Number = 92;
sheet.Range["C5"].Number = 39;
sheet.Range["C6"].Number = 55;
//Create a Chart
IChartShape chart = sheet.Charts.Add();
chart.LeftColumn = 5;
chart.RightColumn = 11;
chart.Name = "Student Sample Chart";
chart.ChartType = ExcelChartType.Cone_Clustered_3D;
chart.DataRange = sheet.Range["B2:C6"];
//Create a font style for RichText
IFont font = chart.ChartTitleArea;
font.Color = ExcelKnownColors.Orange;
font.FontName = "Broadway";
//Set the rich text font
chart.ChartTitleArea.Text = "Sample Chart";
IChartRichTextString richText = chart.ChartTitleArea.RichText;
richText.SetFont(0, 5, font);
//Get the RichText length or count
int richTextLength = chart.ChartTitleArea.RichText.Text.Length;
if (richTextLength != 0)
{
//Your code here
}
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}
Methods
SetFont(Int32, Int32, IFont)
Sets the specified font formatting for the specified range of characters in chart title.
Declaration
void SetFont(int iStartPos, int iEndPos, IFont font)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | iStartPos | First character of the range. |
System.Int32 | iEndPos | Last character of the range. |
IFont | font | Font to set. |
Remarks
To know more about charts refer this link.
Examples
The following code illustrates how to use the SetFont method.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].Text = "Student ID";
sheet.Range["B1"].Text = "Student Name";
sheet.Range["C1"].Text = "Mark(Out of 100)";
sheet.Range["A1:C1"].AutofitColumns();
sheet.Range["A2"].Number = 1;
sheet.Range["A3"].Number = 2;
sheet.Range["A4"].Number = 3;
sheet.Range["A5"].Number = 4;
sheet.Range["A6"].Number = 5;
sheet.Range["B2"].Text = "Andrew";
sheet.Range["B3"].Text = "Marson";
sheet.Range["B4"].Text = "Jack";
sheet.Range["B5"].Text = "Sam";
sheet.Range["B6"].Text = "Breto";
sheet.Range["C2"].Number = 77;
sheet.Range["C3"].Number = 45;
sheet.Range["C4"].Number = 92;
sheet.Range["C5"].Number = 39;
sheet.Range["C6"].Number = 55;
//Create a Chart
IChartShape chart = sheet.Charts.Add();
chart.LeftColumn = 5;
chart.RightColumn = 11;
chart.Name = "Student Sample Chart";
chart.ChartType = ExcelChartType.Cone_Clustered_3D;
chart.DataRange = sheet.Range["B2:C6"];
//Create a font style for RichText
IFont font = chart.ChartTitleArea;
font.Color = ExcelKnownColors.Orange;
font.FontName = "Broadway";
//Create a RichTextString object
chart.ChartTitleArea.Text = "Sample Chart";
IChartRichTextString richText = chart.ChartTitleArea.RichText;
//Sets the specified font formatting for the specified range of characters in chart title
richText.SetFont(0, 5, font);
workbook.SaveAs("Charts.xlsx");
workbook.Close();
}