Excel Charts Are Scaled when Converted to EMF Images in C#

Hi @JThomas98
For CELLSNET57054, our optimized results are as follows, which will take effect in version 24.11.
CELLSNET57054.png (967 Bytes)

Thank you for this! Really appreciate it.

@JThomas98,

You are welcome. We believe all the issues you raised in this thread have been addressed, and the fixes will be included in the upcoming release of Aspose.Cells v24.11. Please feel free to reach out to us if you have any further queries, comments or issue.

1 Like

The issues you have found earlier (filed as CELLSNET-57051,CELLSNET-57052,CELLSNET-57054) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

Hey Aspose Team,
I’m noticing another issue.
The text before the graph is clipped in some cases:
7_25.png (4.6 KB)
This is from the screenshots you shared with me.
Another issue is that this text is being wrapped into multiple lines.
7_13.png (3.1 KB)
7_14.png (1.9 KB)

I was able to replicate these issues with the new version V 24.11 of aspose cells.
Is there some property that I’m missing or is this something you’ll have to address?

@JThomas98
We can reproduce the issue by testing on the latest version v24.11 using sample files and the following sample code. It was found that some texts in front of the graphics were clipped, and some graphic texts were wrapped into multiple lines.

The sample code as follows:

Workbook book = new Workbook(filePath + "Chart_Template1.xlsm");
Chart chart = book.Worksheets["DetailReport"].Charts["DetailChart_PRVSERV"];
ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
imageOptions.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
imageOptions.ImageType = ImageType.Png;
chart.ToImage(filePath + "out_net.png", imageOptions);



chart = book.Worksheets["DetailReport"].Charts["DetailChart_SVCSUSED"];
           
chart.ToImage(filePath + "out_net2.png", imageOptions);

chart = book.Worksheets["DetailReport"].Charts["DetailChart_QUALLIFE"];

chart.ToImage(filePath + "out_net3.png", imageOptions);

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): 
CELLSNET-57199: The text before the graph is clipped when converting chart to image
CELLSNET-57200: Text is wrapped into multiple lines when converting chart to image

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

Hi @JThomas98
For CELLSNET-57199 ( The text before the graph is clipped), our optimized results are as follows, which will take effect in version 24.12.
CELLSNET57199_241120.png (5.6 KB)

This is looking good. Thanks for the update.

@JThomas98,

Thanks for your confirmation. The fixed version (Aspose.Cells v24.12) will be published in the first half of December 2024. We will notify you when the next release is released.

Hi @JThomas98
For CELLSNET-57200, our optimized results are as follows, which will take effect in version 24.12.
7_13_241121.png (3.7 KB)
7_14_241121.png (2.4 KB)

@leoluo,
These charts are looking right.
Thank you for the update!
Looking forward to the new version

@JThomas98,

Thanks for your feedback.

And, sure, we’ll keep you updated on the release of the new version (Aspose.Cells v24.12).

The issues you have found earlier (filed as CELLSNET-57199,CELLSNET-57200) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

Hi Aspose Team,
The issue CELLSNET-57199 is still not fixed in version 24.12.
Here are some screenshots of the text being clipped:
Screenshot 2024-12-10 163116.png (11.6 KB)

Screenshot 2024-12-10 163147.png (5.8 KB)

Hi @JThomas98
We used the Excel file you provided previously and can not reproduce the problem. However, the chart in the previously file does not seem to match the chart with the new problem in screenshot you provided. Please see my screenshot.
241211.png (46.5 KB)

We are sorry about this. Could you please provide the Excel file with the new issues? This would be helpful for us to further optimize this issue. Thank you very much.

Here’s the one I used.
Chart_Template3.zip (766.7 KB)

@JThomas98,

Thanks for the template XLSM file.

I tested your scenario/case with Aspose.Cells for .NET v24.12. I used your template XLSM file and render two charts (“DetailChart_USEDTRANS” and “DetailChart_WEBMATS”) from DetailReport worksheet but I could not reproduce the issue you mentioned. I found no part of text before the charts is clipped.

Workbook book = new Workbook("e:\\test2\\Chart_Template3.xlsm");
Chart chart = book.Worksheets["DetailReport"].Charts["DetailChart_USEDTRANS"];
Chart chart1 = book.Worksheets["DetailReport"].Charts["DetailChart_WEBMATS"];
ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
imageOptions.ImageType = ImageType.Png;
chart.ToImage("e:\\test2\\out_net1.png", imageOptions);
chart1.ToImage("e:\\test2\\out_net2.png", imageOptions);

out_net1.png (3.1 KB)
out_net2.png (3.0 KB)

Let us know if you find any issue with some other charts, which chart (from which worksheet(s))? Could you provide more details with sample code snippet to reproduce the issue on our end, we will check it soon.

Here are some test files I’ve used along with the code sample and outputs.
Charts 1, 2 & 3 are cases where the text is clipped.
Charts 4, 5 & 6 are cases where the text wrapping is different from what it is in excel.
Each of these files have a different template for you to see how it’s happening in all of these templates.
Template1.zip (1.1 MB)

Template2.zip (1.0 MB)

Template3.zip (1.1 MB)

string filePath = @"C:\Documents\Aspose Test\Template2\Chart_Template2.xlsm";
//Load the Excel file
Workbook workbook = new Workbook(filePath);
Chart chart1 = workbook.Worksheets["DetailReport"].Charts["DetailChart_USEDTRANS"];
Chart chart2 = workbook.Worksheets["DetailReport"].Charts["DetailChart_RATETRANS"];
Chart chart3 = workbook.Worksheets["DetailReport"].Charts["DetailChart_WEBMATS"];
Chart chart4 = workbook.Worksheets["DetailReport"].Charts["DetailChart_CPPR"];
Chart chart5 = workbook.Worksheets["DetailReport"].Charts["DetailChart_POPHLTH"];
Chart chart6 = workbook.Worksheets["DetailReport"].Charts["DetailChart_UM"];
ImageOrPrintOptions opts = new ImageOrPrintOptions
   {
        ImageType = ImageType.Png,
        VerticalResolution = 300,
        HorizontalResolution = 300,
        SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality,
        OnlyArea = true
   };
chart1.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net1.png", opts);
chart2.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net2.png", opts);
chart3.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net3.png", opts);
chart4.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net4.png", opts);
chart5.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net5.png", opts);
chart6.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net6.png", opts);

If VerticalResolution, HorizontalResolution, SmoothingMode and OnlyArea properties are not set, the text clipping is even more evident.

string filePath = @"C:\Documents\Aspose Test\Template2\Chart_Template2.xlsm";
//Load the Excel file
Workbook workbook = new Workbook(filePath);
Chart chart1 = workbook.Worksheets["DetailReport"].Charts["DetailChart_USEDTRANS"];
Chart chart2 = workbook.Worksheets["DetailReport"].Charts["DetailChart_RATETRANS"];
Chart chart3 = workbook.Worksheets["DetailReport"].Charts["DetailChart_WEBMATS"];
ImageOrPrintOptions opts = new ImageOrPrintOptions
   {
        ImageType = ImageType.Png
   };
chart1.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net1.png", opts);
chart2.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net2.png", opts);
chart3.ToImage(@"C:\Documents\Aspose Test\Template2\Out_net3.png", opts);

Out_net1.png (1.9 KB)

Out_net2.png (1.7 KB)

Out_net3.png (2.1 KB)

Hi @JThomas98
Thank you for providing the new template files. With these files, we are able to reproduce the issue.
We will prioritize solving the text clipped issue.

For the text wrapping issue, since there is no fixed standard line break position in Excel, it may occur when the percentage width on the right side is changed arbitrarily. We are sorry about this and we will continue to optimize to make it as good as possible.

@JThomas98
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-57418

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.