Free Support Forum -

Aspose.Cells : Backimage for Excel Charts


We have a license for Aspose.Words and Aspose.Cells. 

 I'm looking for the functionality to add a backimage in an Excel Chart within Aspose.Cells. I can only find TextureType and Pattern fill options. However, we need to add the logo of the company.

Does the possibility exist to add such an image like in Excel (Plotarea / Fill effects / 4th tab = image), or do I need to use either the Texture of Pattern functionlity? Can you show me how I can do this (example).

Thanks in advance for your response.

This message was posted using Aspose.Live 2 Forum


Thanks for your inquiry.

Well, setting background image is not supported at the moment. But, you may set Gradient, Texture or Pattern attributes as a fill format for the plot area in your chart. See the following example for reference. In the example I have applied Texture attributes for the plot area and legend’s fill formats.

Sample code:
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Set the name of worksheet
sheet.Name = “Data”;
//Get the cells collection in the sheet.
Cells cells = workbook.Worksheets[0].Cells;

//Put some values into a cells of the Data sheet.

//Add a chart sheet.
int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);
sheet = workbook.Worksheets[sheetIndex];
//Set the name of worksheet
sheet.Name = “Chart”;
//Create chart
int chartIndex = 0;
chartIndex = sheet.Charts.Add(ChartType.Pie, 1, 1, 25, 10);
Chart chart = sheet.Charts[chartIndex];
//Set some properties of chart plot area.
//to set the texture fill color and make the border invisible.
chart.PlotArea.Area.Formatting = FormattingType.Custom;
chart.PlotArea.Area.FillFormat.Texture = TextureType.BlueTissuePaper;
chart.PlotArea.Border.IsVisible = false;

//Set properties of chart title
chart.Title.Text = “Sales By Region”;
chart.Title.TextFont.Color = Color.Blue;
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Size = 12;

//Set properties of nseries
chart.NSeries.Add(“Data!B2:B8”, true);
chart.NSeries.CategoryData = “Data!A2:A8”;
chart.NSeries.IsColorVaried = true;

//Set the DataLabels in the chart
DataLabels datalabels;
for (int i = 0; i < chart.NSeries.Count; i++)
datalabels = chart.NSeries[i].DataLabels;
datalabels.Postion = LabelPositionType.InsideBase;
datalabels.IsCategoryNameShown = true;
datalabels.IsValueShown = true;
datalabels.IsPercentageShown = false;
datalabels.IsLegendKeyShown = false;


//Set the Legend.
Legend legend = chart.Legend;
legend.Position = LegendPositionType.Left;
legend.Height = 100;
legend.Width = 130;
legend.Y = 1500;
legend.TextFont.IsBold = true;
legend.Border.Color = Color.Blue;
legend.Area.Formatting = FormattingType.Custom;
//Set FillFormat.
Aspose.Cells.FillFormat fillformat = legend.Area.FillFormat;
fillformat.Texture = TextureType.Bouquet;
//Save the excel file
workbook.Save(“f:\test\newtest_pie_chart.xls”, FileFormatType.Excel2003);

Also, your feature request has been logged into our issue tracking system (internal) with an issue id: CELLSNET-11502. We will check and analyze the feature for its feasibility if we can support it. We will update you if there is some work done on it.

Thank you.


Please try the attached version v4.8.0.14, we have supported to set a picture as the background image in a chart.

Here is the sample code:

Workbook workbook = new Workbook();
Aspose.Cells.Cells cells = workbook.Worksheets[0].Cells;
FileStream fs = File.OpenRead(@“F:\test\school.jpg”);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
Charts charts = workbook.Worksheets[0].Charts;
charts.Add(ChartType.Column, 0, 0, 10, 5);
charts[0].NSeries.Add(“A1:A2”, true);
charts[0].PlotArea.Area.FillFormat.ImageData = data;


Thank you.


works like a charm. The easiness - is this a word? - and speed of the solution was astounding.

Thanks very very much !