Excel Chart to PNG with Quality

hello,


I have been exploring the Aspose Cell .NET for potential solution for our usecase. i.e.e conmverting excel chart to PNG.

The Quality of PNG generated from Excel chart is good except contrast & brightness. is this a known issue? I have seen other users complaining the same.
Image Contrast not preserved when rendering image from excel

there are options like SmoothingMode, TextRenderingHint provided (not seen much difference with that though), but you dont expose “TextContrast” this interface, which is available on System.Drawing.Drawing2D

Also can you please suggest how can we make improvement in the sharpness of the generated image?

Code snippet:

Worksheet m_worksheet = m_workbook.Worksheets[0];
Charts.Chart m_chart = m_worksheet.Charts[0];
Rendering.ImageOrPrintOptions ops = new Rendering.ImageOrPrintOptions();

ops.VerticalResolution = 300;
ops.HorizontalResolution = 300;

ops.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
// ops.Quality = 100; //is this really required
ops.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

ops.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

m_chart.ToImage(“ChartImage.png”, ops);


Thanks in advance!

Hi,


Thanks for providing us details and sample code.

Could you provide us your template Excel file containing your desired chart, so we could evaluate your issue properly on our end.

By the way, you can try to save to EMF file format type, if it gives you high quality output image for your needs.

Thank you.

Thanks for the quick response!


EMF is not really an option for us as we are looking for it’s alternative.

Please find attached file.
We are trying to Copy Excel chart in MS-Word as EMF v/s PNG generated from AsposeCell .NET to copy to MS-Word.

When we generate PDF (save word file as PDF), you can see the Quality difference.
Given that EMF is vector graphics format it should look better for EMF but is there any support in Aspose to match it?

So far we are only seeing issue related to sharpness (pls look at the attachment for comparison)


Thanks,
Himanshu

Hi Himanshu,

Thanks for your posting and using Aspose.Cells.

We tested this issue with the following sample code with your source Excel file using the latest version: Aspose.Cells
for .NET v8.3.0.3
and did not notice any quality issue.

I have attached the output png image for your reference.

C#


string filePath = @“D:\Downloads\My+test.xlsx”;


Workbook m_workbook = new Workbook(filePath);


Worksheet m_worksheet = m_workbook.Worksheets[0];

Chart m_chart = m_worksheet.Charts[0];

ImageOrPrintOptions ops = new ImageOrPrintOptions();



ops.VerticalResolution = 300;

ops.HorizontalResolution = 300;


ops.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

// ops.Quality = 100; //is this really required

ops.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;


ops.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;


m_chart.ToImage(“ChartImage.png”, ops);