Chart labels are rendered incorrectly when converting to image

Hi Aspose team,
I’m trying to convert a range of cells in excel that contains a chart to an EMF image using the following code:

//Load the Excel file
Workbook workbook = new Workbook(dir + @"\Test_07312025\Chart_template.xlsm");

// Access the worksheet
Worksheet worksheet = workbook.Worksheets["CorrelationAnalysis"];

// Set the print area with your desired range in the worksheet
worksheet.PageSetup.PrintArea = "K2:N37";
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
// Clear any header/footer as they'll be captured when converting the worksheet to image
worksheet.PageSetup.ClearHeaderFooter();

// Set OnePagePerSheet option as true
ImageOrPrintOptions options = new ImageOrPrintOptions()
{
    OnePagePerSheet = true,
    ImageType = Aspose.Cells.Drawing.ImageType.OfficeCompatibleEmf,
    HorizontalResolution = 100,
    VerticalResolution = 100,
    OnlyArea = true,
    SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
};
// Take the image of your worksheet
SheetRender sr = new SheetRender(worksheet, options);
string dataDir = dir + @"\Test_07312025\Out_CorrelationAnalysisK2_N37.emf";

When comparing the chart to the image, you’ll notice that the bottom label highlighted in green and red is rendered with some random characters. Please refer Comparison.jpeg to see what I mean.

Files used for testing:
Test_07312025.zip (1.5 MB)

@JThomas98

It sounds like you’re experiencing issues with chart labels rendering incorrectly when converting an Excel chart to an image format. This can occur due to the chart setup or how the conversion process handles text rendering.

Cause: The rendering issues may stem from missing fonts, low resolution settings, or the specific image format being used.

Solution: Here are several steps to troubleshoot and resolve the issue:

  1. Check Font Settings: Ensure that the fonts used in the chart are available on the system where the conversion is taking place. Missing fonts can lead to incorrect rendering.

  2. Adjust Image Options: Experiment with different image options. For instance, try increasing the resolution settings in your ImageOrPrintOptions to see if that improves the quality of the rendered text.

  3. Use High-Quality Rendering: Set the UseHighQualityRendering property to true in your ImageOrPrintOptions. This can help improve the rendering quality of the chart.

  4. Update Aspose.Cells: Ensure you are using the latest version of Aspose.Cells, as updates often include bug fixes and improvements related to rendering.

  5. Test with Different Formats: If EMF is causing issues, try converting the chart to other formats like PNG or JPEG to see if the problem persists.

Next Steps: Here’s a modified code snippet that incorporates some of these suggestions:

ImageOrPrintOptions options = new ImageOrPrintOptions()
{
    OnePagePerSheet = true,
    ImageType = Aspose.Cells.Drawing.ImageType.Png, // Try PNG or JPEG
    HorizontalResolution = 300, // Increase resolution
    VerticalResolution = 300,
    OnlyArea = true,
    SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality,
    UseHighQualityRendering = true // Enable high-quality rendering
};

// Take the image of your worksheet
SheetRender sr = new SheetRender(worksheet, options);
sr.ToImage(0, dataDir + "ChartImage.png"); // Save as PNG

Try these adjustments and see if they help with the rendering issue. If the problem persists, please provide more details about the specific chart type and any additional settings you are using. Let me know how it goes!

@JThomas98,

Thanks for the template XLSM file and screenshot.

I reproduced the issue as you mentioned by using your sample Excel (XLSM) file and code snippet. I found some chart labels are rendered incorrectly when converting to image. The bottom label is rendered with some random characters.

We require a thorough evaluation of the issue. 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-58826

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

Looking forward to the fix. Thanks.

@JThomas98
Thank you for your feedback. You are welcome. We will notify you promptly once there are any updates.

@JThomas98,

We are pleased to inform you that your issue (Ticket ID: “CELLSNET-58826”) has been resolved. The fix/enhancement will be included in our upcoming release (Aspose.Cells v25.8) that we plan to release during this week. You will be notified when the new version is published.

Hi @amjad.sahi,
Thank you for the update. If you could provide a screenshot of the fix, I’d really appreciate it.

@JThomas98,

Here you go. Please find it attached.
Output.png (6.5 KB)

This is looking good. Thank you!

@JThomas98,

Thank you for confirming. We kindly ask for your patience as the next version (Aspose.Cells v25.8) is expected to be published within the next 2-3 days.

1 Like

The issues you have found earlier (filed as CELLSNET-58826) have been fixed in this update. This message was posted using Bugs notification tool by leoluo