Free Support Forum - aspose.com

Column chart

Hi,

I have created a column chart,I want to display values on each column.How to do this one.Your help is appreciated.

Thanks,

Arun

Hi Arun,

You can try this piece of code:

Excel excel = new Excel();

Cells cells = excel.Worksheets[0].Cells;
cells["a1"].PutValue(2);
cells["a2"].PutValue(5);
cells["a3"].PutValue(3);
cells["a4"].PutValue(6);
cells["b1"].PutValue(4);
cells["b2"].PutValue(3);
cells["b3"].PutValue(6);
cells["b4"].PutValue(7);

cells["C1"].PutValue("Q1");
cells["C2"].PutValue("Q2");
cells["C3"].PutValue("Y1");
cells["C4"].PutValue("Y2");

int chartIndex = excel.Worksheets[0].Charts.Add(ChartType.Column, 11, 0, 27, 13);

Chart chart = excel.Worksheets[0].Charts[chartIndex];
chart.NSeries.Add("A1:B4", true);

chart.NSeries.CategoryData = "C1:C4";

for(int i = 0; i < chart.NSeries.Count; i ++)
chart.NSeriesIdea [I].DataLabels.IsValueShown = true;

Thanks for your quick response.