Message Boards Message Boards

Export a WL-Graphics to Excel?

Posted 7 years ago

I want to export some WL-data together with a graphics generated from that data to MS-Excel (.XLSX). Unfortunately I cannot find the proper syntax for exporting the graphics.

aTable = Table[{x, x^2}, {x, 10}];
aGraphics = ListPlot[aTable];
Export["exported_tmp.xlsx", {{
    "Data" -> Join[{{"The Data"}}, {{"x", "y"}}, aTable],
    "Plot1" -> Join[{{"The Plot Directly From aGraphics"}}, {{aGraphics}}],
    "Plot3" -> Join[{{"The Plot From ExportForm PDF"}}, {{ExportForm[aGraphics, "PDF"]}}], 
    "Plot4" -> Join[{{"The Plot From ExportForm JPEG"}}, {{ExportForm[aGraphics,"JPEG"]}}]
    }}, {{"Sheets"}}
  ];

In all cases the graphics does not appear as an image within Excel, but just as a string.

If I export as an Image like "Plot2" -> Join[{{"The Plot From Image"}}, {{Image[aGraphics]}}] the Excel-File gets even corrupted.

I know, it should be easy to solve that issue, but I was not able for a day or two to get it right.

Attachments:
POSTED BY: Werner Geiger
3 Replies
Posted 7 years ago

Unfortunately I could not solve that until now.

Maybe it becomes clearer if I ask like this:

How can I export some WL-data (say a string) together with a WL-image (generated from a graphics or anything else) on one sheet of an Excel-2007ff (.xlsx) workbook?

POSTED BY: Werner Geiger
Posted 7 years ago

Thanks, Chad. This works indeed. But I cannot see how to get control over the sheet names. And how can I mix different data on one sheet? For example a header line and a graphics? Like in my example above.

POSTED BY: Werner Geiger

Here is one way to do it:

aTable = Table[{x, x^2}, {x, 10}];
aGraphics = ListPlot[aTable];
xfile = Export["exported_tmp.xlsx", {"Sheets" -> aTable, "Images" -> aGraphics}, "Rules"]
POSTED BY: Chad Knutson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract