How to stop grid resizing to window width without explicitly setting size?

I have a series of highly formatted grids of information (text, values, tiny plots, etc) that are formatted by a function. The grids are of different widths and heights as Grid is automatically sizing them to their contexts. They look good in Mathematica.

The problem comes when exporting. They will be exported to PNG images for use outside of Mathematica. If I just Export the images look as the grids on the screen.

g = Grid@{{"Apples", "Oranges", "Peaches", "Pears"}, {100, 200, 300,
400}}

Export[FileNameJoin[{NotebookDirectory[], "good.png"}], g]


However, the image is too small for the intended use. Therefore, I export with Magnify.

Export[FileNameJoin[{NotebookDirectory[], "bad.png"}], Magnify[g, 2]]


As can be seen above, when this is done the grid adjusts its width to the width of the notebook window which results in the loss of layout. You can see this by evaluating Magnify[g, 2] and then slowly decreasing the width of the notebook window.

What option setting on Grid can be set to stop it resizing itself to the notebook window width? I believe Magnify on such a grid would not result in the resizing which would give the expected exported image.

I believe this might be some Style or Text option that I can put in the BaseStyle option of Grid but I have not been able to find it as yet. But this may not be the correct approach.

If the grid is wider then the width of the window the horizontal scrollbar would be used to view the portion wider than the window. This behavior would be similar to how wide Dataset objects are displayed.

g2 = Grid[{{"Apples", "Oranges", "Peaches", "Pears"}, {100, 200, 300, 400}},
ItemSize -> Full]

Import@Export["/tmp/foo.png", Magnify[g, 5]]    (* OP *)


Import@Export["/tmp/foo.png", Magnify[g2, 10]]  (* ItemSize -> Full *)


• So simple. How did I miss this? – Edmund May 1 '17 at 13:55
• @Edmund Zillions of Grid and GridBox options. :) – Michael E2 May 1 '17 at 14:02

The option ItemSize -> All seems to work. The notebook looks like this

and the exported PNG like this