Charts.ToImage quality

Hi.


We are exploring different ways of getting high quality charts in our Word documents since Aspose.Reporting has been discontinued.

The first prize would be if we could used Aspose.Cells to produce the charts, and simply export them as images to Word. Unfortunately, this is not currently a possibility, as the ToImage method produce extremely poor quality pictures: The shading is gone, and the edges are pixelated.

Yet it should be possible to export these charts to identical images, because when I open the Excel file, and manually copy and paste the chart to Word, I get an image that looks exactly like the chart in Excel.

Are you planning to improve the quality of the images produced by the ToImage method in the near future, and, if yes, when can we expect the release?

The answer is critical to our “going forward” strategy.

Thanks

Hi,

We recommend you to try some vector graphics formats e.g emf, tiff (with enhanced resolutions) to
take the image of the chart and then paste into the word document.e.g

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = ImageFormat.Tiff;
imgOptions.HorizontalResolution = 300;
imgOptions.VerticalResolution = 300;
imgOptions.TiffCompression = TiffCompression.CompressionLZW;
chart.ToImage(“e:\test\myfile.tif”, imgOptions);

If you still find significant issue regarding chart’s quality, kindly give us your code segment regarding Aspose.Cells for .NET API to take the image, attach your output image file and sample Excel file (containing the chart) etc., we will look into it soon.

Thank you.


Hi Amjad.

Please see the document attached. As you can see, even though your solution has solved the pixelated problem, there is still drop in quality.

* The bigest concern is that no provision is made to prevent labels from running into each other.

* Also, the font settings used in the image is not the same as in the original.

* Lastly, there is a clear difference in quality of the graphics as well, though admittedly it's no longer so bad that you can't show it to a client. This is a minor issue that we can overlook, but the first two issues is problematic.

I will therefore have to continue to investigate options.

Regards.

Hi,

Kindly attach your source Excel file (containing the sample chart), we will try to evaluate and figure your first two issues.

By the way, which version of the product you are using and did you try our latest version/fix Aspose.Cells for .NET v5.3.2.1

Thank you.

Thank you for your reply.

As it happens, we did download the newest version of Aspose.Totals this week from http://www.aspose.com/community/files/51/.net-components/aspose.total-for-.net/entry87871.aspx from http://www.aspose.com/community/files/default.aspx. I noticed that it did not contain any changes for Aspose.Cells, so we're still using 5.1.2.0

Could you please send me a link where I can download version 5.3.2.1 ?

Also, please find the requested spreadsheet attached.

Thanks.

Hi,

You can download Aspose.Cells for .Net v5.3.2.1 and also it's Client Profile Version.

Thank you

Hi,

I have tested converting your chart in your template file with v5.3.2.2 (you may get it from here). For your second issue regarding font’s quality, it works fine and provide better result if we save it to emf format. e.g
var options = new ImageOrPrintOptions();
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
Workbook wb = new Workbook(“e:\test2\charttoimage_quality\test.xlsx”);
Chart chart = wb.Worksheets[0].Charts[0];
chart.ToImage(@“e:\test2\charttoimage_quality\emfoutput.emf”, options);
I have attached my output image.

Also, I am afraid, currently we don’t support leader lines in Pie chart, we will support it in future versions.

Thank you.

I might be making a fool of myself, but I figure since I struggled with this, someone else might find it useful as well.


The quality of the image is also affected by the type of Workbook you’re using.

If you just go
Workbook book = new Workbook();

you will most probably be disappointed with the image. Instead, declare your workbook as follows:
Workbook book = new Workbook(FileFormatType.Xlsx);

I hope this saves somebody some time.

regards

Hi,


Thank you for your interest in Aspose Products and your valuable findings. We will surely test the quality of image using variance of Workbook constructors and let you know the results here.

Thanks again.

Hi.

One more question. I have the following line of code that formats the text on my pie segments:

series.Points[i].DataLabels.Text = e.DataPointLabel + "\r\n" + e.DataPointValue.ToString(DefinitionProperties["###%"]);

In Excel, the text appears as expected. However, when I "toImage" the graph, instead of having a label that says : "Global Equity 12%", I have a label that just says "0.12".

Is this me doing something wrong, or is customization of the DataLabels.Text not supported in the "toImage" functionality?

I noticed this was logged as a bug last year in the Java version. I suspect the bug still exists for .Net? <A href="</A></P> <P>Oh, and one more thing, the labels in the image appear much larger and bolder than it does in excel. Is it possible that we could have that fixed too?</P> <P><FONT size=2><FONT size=3>Thanks</FONT></P></FONT>

Hi,

Please post your generated Excel file (you may save an Excel file containing the updated chart) and output image file, we will check your issue soon.

Thank you.

Hi.

Thanks for the quick response.

Please find both the Excel file and the Word doc attached.

Regards

I have tested your file converting the chart into image file using Aspose.Cells for .NET v5.3.2.6, it works OK, I have attached the output file using the sample code:

var options = new ImageOrPrintOptions();
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
Workbook wb = new Workbook(“e:\test2\ReportTest1.xlsx”);
Chart chart = wb.Worksheets[0].Charts[0];
chart.ToImage(@“e:\test2\outputImage.emf”, options);

Please try v5.3.2.6.

Thank you.

I just found this post from 2007 as well: https://forum.aspose.com/t/102324

I couldn't figure out whether this post applies to .Net, but in it, the "DataLabels.Text not reflecting on the image" issue was reported as well. In the second last post, Roger Mo reported that the issue will be fixed within that week, so I'm assuming it won't be a big deal to fix.

Hi,

Please check my previous post in this thread.

Thank you.

Thanks so much.

That is reasuring. I'll check through my code to see where I've done it wrong.

Hi,

If you are still not able to generate expected images, please post the whole code you used.

The code should reflect how did you create chart objects using Aspose.Cells API and inserted chart images to word document using Aspose.Words API.

Note:
Aspose.Cells support converting most of the charts to images except bubble 3d and surface chart and it also support most of the features except Perspective ( 3D Rotation --> 3D Format --> Rotation), 3-D Format, Shadow and placing some complex DataLabels of Points of 3D Pie chart to suitable location when the Label Position of the DataLabels are Best Fit.

For further help, please see these images

Hi Shakeel.

I noticed we were still on version 5.1.2.0, and after the update, I've been quite busy replacing the Style property with the GetStyle and SetStyle methods throughout the project.

However, I was able to confirm that the correct label text is now reflected on the image, so I think I'll be ok from here on.

Thanks so much for your help.

Hi,

Thanks for your feedback.

Anyway, I have changed the topic of my above post, so that you or others could find it more easily. It is useful for those who want to know which of chart types and chart features are supported/unsupported by Aspose.Cells API.

Hi


Sorry for troubling again, but my pixelated problem is back again, and non of the suggestions in this post seems to help (See attached)

I’ve tried changing the ImageOrPrintOptions, but nothing seems to make any difference:

public override void AddChart(ChartTemplateTypes chartLayoutType, string titleText, ChartLegendLayoutTemplateTypes legendLayoutType)
{
ExecuteSectionBreaks();
DocApplyTabStops();

base.AddChart(chartLayoutType, titleText, legendLayoutType);

Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.ImageFormat = ImageFormat.Tiff;
options.HorizontalResolution = Convert.ToInt32(StylesRoot.ChartTemplates[chartLayoutType].Width * 1000);
options.VerticalResolution = Convert.ToInt32(StylesRoot.ChartTemplates[chartLayoutType].Height * 1000);
options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionCCITT4;

Image chartImage = _xlsChart.ToImage(options);
AddImage(ImageLayoutTemplateTypes.RelativeToCursorForeGround, chartImage);

}

I’ve tried setting the TiffCompression, changing the resolution, setting the image format to Emf, setting the Quality property, but nothing seems to help. It’s almost as if the ToImage method does not take these properties into account.

Am I missing something?