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?
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?
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.
Export
statement? I studied the docs, but can not figure this out.
$\endgroup$
Jul 6, 2012 at 16:31
Export["multipleImages.xls", {CompleteGraph[#] & /@ {5, 7, 9}, {}}, {{"Images", "Sheets"}}]
or Export["multipleImages2.xls", {{}}, "Images" -> (CompleteGraph[#] & /@ {5, 7, 9})]
both work to export several graphs.
$\endgroup$
If you need a basic data behind the graph, the AdjacencyMatrix
I think is good for tabular formats. This will work:
Export["graph_data.xls", AdjacencyMatrix[CompleteGraph[13]]]
"graph_data.xls"
If you need the image of the graph object, in addition to programmatic way (see @kguler answer) there is an interactive way I personally use often. The steps (on win7):
Export
statement.
$\endgroup$
Jul 6, 2012 at 16:35