In each cell of an \(n \times n\) grid, one of the numbers \(0\), \(1,\) or \(2\) must be written. Determine all positive integers \(n\) for which there exists a way to fill the \(n \times n\) grid such that, when calculating the sum of the numbers in each row and each column, the numbers \(1, 2, \ldots, 2n\) are obtained in some order.
To solve this problem, we need to determine all positive integers \( n \) for which there exists a way to fill an \( n \times n \) grid with the numbers \( 0, 1, \) or \( 2 \) such that the sums of the numbers in each row and each column are the numbers \( 1, 2, \ldots, 2n \) in some order.

1. **Sum of All Numbers in the Grid:**
   The sum of all numbers in the grid must be equal to the sum of the numbers \( 1, 2, \ldots, 2n \). The sum of the first \( 2n \) positive integers is given by:
   \[
   \sum_{i=1}^{2n} i = \frac{2n(2n+1)}{2} = n(2n+1)
   \]
   Let \( S \) be the sum of all numbers in the grid. Since each cell contains either \( 0, 1, \) or \( 2 \), the total sum \( S \) must be even. Therefore, \( n(2n+1) \) must be even.

2. **Parity Condition:**
   For \( n(2n+1) \) to be even, \( n \) must be even because \( 2n+1 \) is always odd. Let \( n = 2k \) for some positive integer \( k \).

3. **Constructing the Grid:**
   We need to construct the grid for \( n = 2k \) such that the sums of the rows and columns are \( 1, 2, \ldots, 2n \) in some order. We can achieve this by filling the grid as follows:
   
   - For rows \( 1 \) to \( k \) (i.e., the first half of the rows), fill each row \( i \) with \( i \) ones at the beginning and the rest with zeros.
   - For rows \( k+1 \) to \( 2k \) (i.e., the second half of the rows), fill each row \( i \) with \( 2k-i \) ones at the end and the rest with twos.

4. **Example for \( n = 8 \):**
   Let's illustrate this with an example for \( n = 8 \) (i.e., \( k = 4 \)):
   \[
   \begin{array}{cccccccc}
   1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
   1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
   1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\
   1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
   2 & 2 & 2 & 2 & 2 & 2 & 2 & 1 \\
   2 & 2 & 2 & 2 & 2 & 2 & 1 & 1 \\
   2 & 2 & 2 & 2 & 2 & 1 & 1 & 1 \\
   2 & 2 & 2 & 2 & 1 & 1 & 1 & 1 \\
   \end{array}
   \]

5. **Verification:**
   - The sums of the rows are \( 1, 2, 3, 4, 15, 14, 13, 12 \).
   - The sums of the columns are \( 5, 6, 7, 8, 9, 10, 11, 16 \).

   These sums are exactly the numbers \( 1, 2, \ldots, 2n \) in some order.

Conclusion:
Thus, the only positive integers \( n \) for which such a grid can be constructed are the even integers.

The final answer is \( \boxed{ n } \) must be even.