3

How do i export an Excel chart to a PNG image, defining the exact size of the resulting image file?

I need to export some excel charts to PNG to put them on a html page. Due to design restrictions, there's a maximum width (say, 450px) for those PNGs. I've already found a lot of instructions how to export the charts to PNG, but in every case, i had to resize the resulting PNG down to the target dimensions, loosing quality. Is there a way to make Excel use certain dimensions when exporting a chart?

Ways i've tried to create the PNGs:

I'm using Office 2010 currrently.

EDIT:

Modifying the size of the charts inside the Excel file would make it possible to "predict" the resulting PNG image size, but it would be great if there's a way of setting the image size without resizing the chart itself, e.g. to create PNGs with different, but pre-defined sized based on the same chart.

EDIT 2:

There's a useful tool named XL toolbox that allows to "publish" charts with a defined print size using pt, mm or in. This isn't exactly what i'm needing, since the tool seems to resize the image, too, with a slight loss of quality.

tohuwawohu
  • 11,143

2 Answers2

1

When I export from Excel, my .png images are about 1" = 151px.

To get a perfect 450px wide image, I set my Chart width to 2.99" (direct enter the value on the Width box on the Format Tab).

To verify, paste into MS Picture Manager and check the size setting summary. Then adjust as necessary. FWIW, my Excel 2007 on a different box behaves slightly different, but they are both internally consistent-so I only had to figure out my measurements once per machine.

dav
  • 10,618
1

Here are a couple tutorials with some VBA code that will export a chart as an image file: Export Chart as Image File and Enhanced Export Chart Procedure.

Jon Peltier
  • 4,630
  • 24
  • 27