It is straightforward to export lists to Excel with Export
. Can I export a graphic image, too? This does not work:
g = CompleteGraph[4];
fnOut = "Output1.xls";
Export[fnOut, {"Sheet1" -> g}]
Maybe I need to transform g
in some way?
Answer
You can export both data and the images using one of several syntax patterns that you find in the docs on XLS format:
For example:
g = CompleteGraph[7];
Export["output1.xls",
{g, {"mySheet1" -> Normal@AdjacencyMatrix[g]}}, {{"Images", "Sheets"}}]
gives
EDIT: Exporting multiple images:
It seems you need at least one sheet (which could be empty) as part of any export. With this restriction,
Export["multipleImages.xls", {CompleteGraph[#] & /@ {5, 7, 9}, {}},
{{"Images", "Sheets"}}]
or
Export["multipleImages2.xls", {{}}, "Images" -> (CompleteGraph[#] & /@ {5, 7, 9})]
or
Export["multipleImages3.xls",
{"Sheets" -> {}, "Images" -> (CompleteGraph[#] & /@ {5, 7, 9})}, "Rules"]
all work to export several images.
Comments
Post a Comment