One option would be to use TikZ and a matrix of nodes:
\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[
every node/.style={minimum width=1.6cm,text height=12pt,text depth=6pt},
texto/.style={minimum width=10pt,text height=6pt,text depth=2pt},
textoi/.style={draw,minimum width=10pt,text height=6pt,text depth=2pt}
]
% The matrix with some cells initially with no visible contents
\matrix[matrix of nodes] (mat)
{
\null & $D_1$ & $D_2$ & $D_3$ & $D_4$ & \text{Supply} \\
$S_1$ & \null & \null & \null & \null & 8 \\
$S_2$ & \null & \null & \null & \null & 14 \\
};
% We typeset the numbers in the upper left corner of the first row:
\foreach \col/\cont in {2/5,3/12,4/7,5/48}
\node[texto,anchor=north west] at (mat-2-\col.north west) {\cont};
% We typeset the numbers in the upper left corner of the second row:
\foreach \col/\cont in {2/3,3/16,4/34,5/25}
\node[texto,anchor=north west] at (mat-3-\col.north west) {\cont};
% We typeset the numbers in the colored box in the lower right corner of some cells in the first row:
\node[fill=green,textoi,anchor=south east] at (mat-2-2.south east) {6};
\node[fill=green,textoi,anchor=south east] at (mat-2-3.south east) {16};
% We typeset the numbers in the colored box in the lower right corner of some cells in the second row:
\node[fill=green,textoi,anchor=south east] at (mat-3-3.south east) {11};
\node[fill=green,textoi,anchor=south east] at (mat-3-4.south east) {9};
% We draw horizontal rules in the table
\foreach \i in {1,...,3}
\draw (mat-\i-1.north west) -- (mat-\i-6.north east);
\draw (mat-3-1.south west) -- (mat-3-6.south east);
% We draw vertical rules in the table
\foreach \i in {1,...,6}
\draw (mat-1-\i.north west) -- (mat-3-\i.south west);
\draw (mat-1-6.north east) -- (mat-3-6.south east);
\end{tikzpicture}
\end{document}
