1

I tried to export charts as images with Microsoft.Office.Interop.Excel.Chart.Export() method, but the quality of the images is bad (best result is with the PNG format). Is there any way how to set the resolution of images during export using only Microsoft.Office.Interop?

On the other hand, my coworker is using VBA and he can export charts as .emf files directly from Excel (using WinAPI), so I tried including them using the Microsoft.Office.Interop.Word.InlineShapes.AddPicture() method, but it seems that it cannot include .emf files directly.

Is there a different and maybe better way to do this?

UPDATE: I don't know why I thought that it is not possible include .emf file, but still I want to export hi-res images.

uetoyo
  • 329
  • 1
  • 3
  • 11
  • An idea would be to save it as an image then import it into the document. SO question: http://stackoverflow.com/questions/1716221/use-excel-interop-to-grab-image-of-excel-chart-without-writing-to-disk-or-using – Andrew Grinder Aug 04 '14 at 18:11
  • It seems that SpreadsheetGear.NET is not free. – uetoyo Aug 04 '14 at 18:19
  • What about using the `AddOleObject()`? – uetoyo Aug 04 '14 at 18:25
  • Ya I was looking into it, that sucks. Try this one: http://stackoverflow.com/a/4997875/2367343 – Andrew Grinder Aug 04 '14 at 18:25
  • I really don't understand why there is no option for the quality of image when using the `Microsoft.Office.Interop.Excel.Chart.Export()`, or chosing some vector format. – uetoyo Aug 04 '14 at 18:28

1 Answers1

1

It's ugly but how about enlarging the chart before you export it as such:

    myChart.ScaleWidth(2, msoFalse, msoScaleFromTopLeft);
    myChart.ScaleHeight(2, msoFalse, msoScaleFromTopLeft); 

and then after export, if you need to, shrink it back by replacing 2 with .5...

When you import it into Word, you can perform ScaleWidth and ScaleHeight on the shape to get it the size you need.

Snorex
  • 904
  • 12
  • 29