It is called a magic square and there are various tricks to make your custom magic square. I have memorised 3*3 magic square. For 7*7, you can find it in various maths books. You can find the common sum of the diagonals/columns/rows in the following way if the magic square has consecutive numbers starting from 1.:-
let number of columns=rows=x
You can find the methods to create magic squares in other books/e-books as it is impossible to explain here.