Cannot set ShowValue option for the chart when saving an Excel 97-2003 file format using Aspose.Cells for Java

Hi all,
I’m trying to set ShowValue = false for all point of chart but it not working when I save excel as 97-2003 format.
Pls help me. Thanks!

@DungLT,

Thanks for providing us some details.

Please provide us sample code (runnable) and template file to show the issue, we will check it soon.

I’m using XYPlot chart and here is my code:
var _pointCount = _chart.NSeries[_i].Points.Count;
for (var _j = 0; _j < _pointCount; _j++)
{
var _point = _chart.NSeries[_i].Points[_j];
_point.DataLabels.ShowValue = false;
}
demoExport.zip (3.3 KB)

@DungLT,

Thanks for the template file and sample code segment.

After an initial test, I am able to observe the issue as you mentioned by using the following sample code with your template file. I found that I could not hide the data labels values using ShowValue option for the chart when saving an Excel 97-2003 file format:
e.g
Sample code:

 Workbook wb = new Workbook("e:\\test2\\demoExport.xls"); 
            Worksheet ws = wb.Worksheets[0]; 
            Chart chart = ws.Charts[0]; 
             
//This does not work either 
            /* 
            foreach (Series series in chart.NSeries) 
            { 
                series.DataLabels.ShowValue = false; 
            } 
            //chart.Calculate(); 
            */ 

            foreach (Series s in chart.NSeries) 
            { 
                Console.WriteLine(s.Points.Count); 
                for (int i = 0; i < s.Points.Count; i++) 
                { 
                    ChartPoint p = s.Points[i]; 
                    p.DataLabels.ShowValue= false; 
                    //p.DataLabels.ShowCellRange = false; 



                } 
            } 

            wb.Save("e:\\test2\\out1.xls"); 

I have logged a ticket with an id “CELLSNET-46432” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

1 Like

@DungLT,

Could you try the following code segment while generating the output file. I have tested it and it works fine:
e.g
Sample code:

      Workbook wb = new Workbook("e:\\test2\\demoExport.xls");
            Worksheet ws = wb.Worksheets[0];
            Chart chart = ws.Charts[0];
            
             foreach (Series s in chart.NSeries)
            {
                s.DataLabels.ShowValue = false;
                int pCount = s.Points.Count;
                for (int i = 0; i < pCount; i++)
                {
                    ChartPoint p = s.Points[i];
                    p.DataLabels.ShowValue = false;
                }
            }

            wb.Save("e:\\test2\\out1.xls");

Let us know your feedback.

PS. Now setting the data label of chart points seem to be not user friendly. We must also set the data label of series at the same time. This module is too complex to sort it out. In short, you have to devise the workaround (we won’t fix this issue) as above for your needs.

Tks for your support.
But, it work fine beacause it have
s.DataLabels.ShowValue = false;

But I want to use point to set visible for it :frowning:

@DungLT,

Please read PS. in our previous reply for your reference.

If you still have any issue or confusion, do let us know with details, sample code (runnable) and template files to show the issue, we will check it soon.