How to save an Excel chart directly to an image file

From CCoWS Wiki
Revision as of 10:26, 24 February 2009 by Cooperf (Talk | contribs)

Jump to: navigation, search

Its very handy to be able to convert Excel charts directly to image files, so you can do things like post the on wiki pages.

The best format for this is PNG, since it handles fonts, lines, and images all at once. Formats like GIF, BMP, and JPG are not as good, because they only store images, and the convert fonts and lines to ugly looking images before saving them. PDF is ok, but not as versatile for rapid viewing and thumbnailing on web pages, or embedding in other documents.

There are many ways to do export from Excel charts to images.

Option 1

This is perhaps the best option.

  1. In Excel:
    1. Select the chart
    2. Select Save As
    3. Change file type to "Web page (*.htm)"
    4. Change options to save "Selection"
    5. Enter file name "tmp.htm"
    6. Select OK, or Publish or whatever is needed to say you're done.
  2. Then, in Windows Explorer:
    1. Look for tmp.htm
    2. Look for a folder in the same place called "tmp_files"
    3. Look for image files in that folder, preferably the PNG, since this will be best quality
      1. If no PNG appears, then you need to change Excel Options (see below), and start over
    4. Put the PNG where you need it
    5. Delete tmp.htm (this wil also delete the tmp_files folder
  3. Changing Excel Options to save web pages with PNG images (see above)
    1. In Excel 2003 and earlier:
      1. Tools --> Options --> select the General tab --> click Web Options --> select Browsers tab -->
  under options select "Allow PNG as a graphics format" check box 
    1. In Excel 2007:
      1. This might work:
        1. Menu --> Windows Symbol --> Excel Options --> Advanced --> General --> Web Options --> "Allow PNG as Graphics Format"

Option 2

Write a script to do it:

Sub export() fileSave = Application.GetSaveAsFilename( _ InitialFileName:="xlchart.png", _ fileFilter:="PNG File (*.png), *.png,GIF File (*.gif), *.gif") If fileSave <> False Then ActiveChart.export fileSave, Right(fileSave, 3) End If End Sub

This is from http://www.bogleheads.org/forum/viewtopic.php?t=639&sid=defa2b6c9c83f466e05de8ec2c66b3de

I haven't tried it, but it looks very promising for geeky types.

Option 3

Save to PDF, and then save PDF as PNG. Not bad, but requires that you manually crop your image out of the PDF page.

Option 4

Copy and paste to image program like Paint or PhotoShop. Ugly, because it rasterizes the fonts and lines.

Links