We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Format Data Labels

I am trying to change the data label options from value to category name, but cannot quite figure it out. Please advise.

Hi,

Thanks for your posting and using Aspose.Cells.

If you want to show category name, then please set chart.NSeries[0].DataLabels.ShowCategoryName as true and if you want to hide value, then please set chart.NSeries[0].DataLabels.ShowValue to false

Please see the following code. I have attached the source Excel file used in this code and output Excel file generated by it for your reference.

C#


Workbook workbook = new Workbook(“source.xlsx”);


Chart chart = workbook.Worksheets[0].Charts[0];


chart.NSeries[0].DataLabels.ShowCategoryName = true;

chart.NSeries[0].DataLabels.ShowValue = false;


workbook.Save(“output.xlsx”);


I don’t have ShowCategoryName or ShowValue, But I did find IsCategoryNameShown and it worked great, I also had to shut the IsValueShown off, see below

chart3.NSeries[1].DataLabels.IsCategoryNameShown = true;
chart3.NSeries[1].DataLabels.IsValueShown = false;

Now, if you can tell me how to make the first series transparent, I tried

        chart3.NSeries[0].DataLabels.Area.ForegroundColor = Color.Transparent;

as well as

        chart3.NSeries[0].DataLabels.Background = BackgroundMode.Transparent;

neither worked.

Hi,

Thanks for your posting and using Aspose.Cells.

It seems, you are using the older version, please use the latest version: Aspose.Cells for .NET (Latest Version) as these properties are obsolete and will be removed soon.

Please use chart.NSeries[0].Area.Formatting = FormattingType.None to hide the series totally. Please see the following code for your reference.

C#


Workbook workbook = new Workbook(“source.xlsx”);


Chart chart = workbook.Worksheets[0].Charts[0];


chart.NSeries[0].Area.Formatting = FormattingType.None;


workbook.Save(“output.xlsx”);