I have a Mathematica expression generated by another program, which I would like to open in a notebook, properly formatted. For instance, the other program generates this:<
You can use the following wrapping:
nb = CreateWindow[
DocumentNotebook[{
Plot[{Exp[x],
Interpolation[Table[{k/5, Exp[(k - 1/2)/5]}, {k, 0, 5}],
InterpolationOrder -> 0][x]}, {x, 0, 1},
Filling -> {1 -> {{2}, {Yellow, Orange}}},
PlotLabel ->
Style["Formatting", Blue, FontFamily -> "Courier"]]
}]]
then commands NotebookSave and NotebookClose can be used to save and close the thing ;)