Show / Hide Table of Contents

Set and format Chart Title

Set the chart title to "Title" and format the fill color to bisque, the border color to aquamarine. Set the font to Consolas the size to 16, and the color to red.

Output: TitleFormat.xlsx

var workbook = new Workbook();
var worksheet = workbook.Worksheets[0];

worksheet.GetRange("J1:L1").SetValue(new[] { "Series 1", "Series 2", "Series 3" });
worksheet.GetRange("I2:I5").SetValue(new[] { "Point 1", "Point 2", "Point 3", "Point 4" });
worksheet.GetRange("J2:J5").SetValue(new[] { 2, 4, 6, 8 });
worksheet.GetRange("K2:K5").SetValue(new[] { 4, 3, 2, 1 });
worksheet.GetRange("L2:L5").SetValue(new[] { 2, 1, -1, -2 });

var chart1 = worksheet.Charts.Add<LineChart>("A1");
chart1.Size.HeightInches = 2.5;
chart1.Size.WidthInches = 3.5;
chart1.DataSource = "Sheet1!$I$1:$L$5";

chart1.Title = new Title();
chart1.Title.FormattedText.Text = "Title";
chart1.Title.FormattedText.Font.Size = 16;
chart1.Title.FormattedText.Font.Name = "Consolas";
chart1.Title.FormattedText.Font.Color = Color.Red;
chart1.Title.Fill.SolidColor = Color.Bisque;
chart1.Title.Border.Color = Color.Aquamarine;

workbook.SaveAs("TitleFormat.xlsx");
Back to top Generated by DocFX