Generate a grid of sums Generate a 7 by 7 grid, filled with random numbers. However, in cells with an odd row and column number (starting at 0), you must use the sum of the surrounding cells. Here's a small example with a 3 by 3 grid (sum-square bolded):

2 2  2
2 16 2
2 2  2

And here's an example 7 by 7 grid:

6 5  4 3  7 2  5
6 43 3 50 8 43 8
4 7  8 8  9 3  1
4 36 1 43 6 40 5
3 3  6 1  4 7  5
4 35 3 45 9 42 1
2 6  8 6  8 5  3

Rules


Numbers that are not sums must always be between 1 and 9 inclusive.
Grid must be randomly generated. For each non-sum, every digit must have an equal chance of appearing, regardless of which cell it is in.
Numbers must be aligned. This means that either the first or last digit of each number in a column must line up vertically. (You may assume that the middle numbers will always be two digits.)
Surrounding cells includes diagonals. Therefore, each sum square will have eight numbers surrounding it, which you must add.
Shortest code wins, since this is code-golf.
APL, 53 49 43 42 40 39 36

I managed to replicate J's ;. in APL, and used Gareth's approach, saving 13 chars.

{×5⌷⍵:5⌷⍵⋄+/⍵}¨3,⌿3,/×∘?∘9¨∘.∨⍨9⍴0 1


Sample run:

      {×5⌷⍵:5⌷⍵⋄+/⍵}¨3,⌿3,/×∘?∘9¨∘.∨⍨9⍴0 1
9  9 6  1 7  5 6
7 55 5 39 9 54 9
9  8 2  1 8  1 9
2 43 8 41 6 42 5
7  3 4  4 8  3 2
2 29 1 26 2 35 8
6  4 2  3 2  3 7




Explanation:


∘.∨⍨9⍴0 1 generates a bit mask.
×∘?∘9¨ multiplies each bit by a random value from 1 to 9 inclusive, generating a masked grid of random numbers.
3,⌿3,/ uses what can only be described as hackery to return all 3 by 3 overlapping boxes in the masked array. These are also flattened in the process.
{×5⌷⍵:5⌷⍵⋄+/⍵}¨ iterates over the array, assigning each element to ⍵. For each iteration, it takes the fifth (middle, remembering that APL indexing is 1-based), and returns its sign. In this case this is equivalent to testing if the number is greater than 0. If this returns 1 (for true), then return that element. Otherwise, return the sum of the elements in the flattened 3 by 3 box. It uses the :⋄ ternary operator, which is the equivalent of ?: in many languages.