Hello,
We have encountered the following issue. Saving the pie chart from our workbook as image ends in losing a label from the original chart.
Here is the following code used to reproduce this issue, along with the attached file:
----------
var workbook = new Workbook(“testFile.xlsx”);
var worksheet = workbook.Worksheets[0];
const string chartName = “ProductionPie”;
var chart =
worksheet.Charts.FirstOrDefault(x => chartName.Equals(x.Name, StringComparison.OrdinalIgnoreCase));
if (chart == null)
return;
chart.ToImage().Save(@“out.png”);
----------
InternalId: 21485
Best regards,
Jean-Alexandru Stanescu
Junior Developer
IBM Romania
Hi,
Sample code:
var workbook = new Workbook(“e:\test2\testFile.xlsx”);
var worksheet = workbook.Worksheets[0];
var chart = worksheet.Charts[0];
if (chart == null)
return;
chart.ToImage().Save(@“e:\test2\out1.png”);
Hi,
Thanks for using Aspose.Cells.
The position of label that is not seen in the chart is automatic. If the labels can be placed well in the slice of pie, the position will be Inside, otherwise Outside.
For this label, Excel is Inside, Aspose is Outside. As it is too complex to figure out the proper position when the position is automatic, we cannot fix the issues now. You may make the label shown by setting the plot area’s color and labels’ font color different using the following code segment before converting to image.
C#
chart.ChartArea.Area.ForegroundColor = Color.FromArgb(85, 142, 213);
chart.ToImage().Save(@“out.png”);
Please try our latest version Aspose.Cells 21.6.0.
If you find any issue, please provide the source Excel file to help us analyze it.