[step:Write $A$ in block form with respect to the chosen basis]We compute the matrix $[A]_\mathcal{B}$ of $A$ with respect to the basis $\mathcal{B}$.
**Action on $W$-basis vectors.** For each $i \in \{1, \ldots, k\}$, the hypothesis $A(W) \subseteq W$ gives $A(w_i) \in W$, so $A(w_i)$ is a linear combination of $w_1, \ldots, w_k$ alone:
\begin{align*}
A(w_i) = \sum_{i'=1}^{k} B_{i'i}\, w_{i'}.
\end{align*}
The coefficients $B_{i'i}$ form the $k \times k$ matrix $[B]_{(w_i)} = (B_{i'i})$ of $B = A|_W: W \to W$ in the basis $(w_1, \ldots, w_k)$.
**Action on complementary basis vectors.** For each $j \in \{1, \ldots, \ell\}$, the image $A(v_j) \in V$ expands in the full basis as
\begin{align*}
A(v_j) = \sum_{i=1}^{k} A'_{ij}\, w_i + \sum_{j'=1}^{\ell} C_{j'j}\, v_{j'}
\end{align*}
for some scalars $A'_{ij}, C_{j'j}$. Applying $\pi$ to both sides kills the $w_i$ terms; and since $A$ preserves $W$, the induced quotient map $C: V/W \to V/W$ is well-defined, $C(\pi(v)) = \pi(A(v))$, so
\begin{align*}
C(\pi(v_j)) = \pi(A(v_j)) = \sum_{j'=1}^{\ell} C_{j'j}\, \pi(v_{j'}).
\end{align*}
The coefficients $C_{j'j}$ are therefore the entries of the $\ell \times \ell$ matrix $[C]_{\bar{\mathcal{B}}} = (C_{j'j})$ of $C$ in the basis $\bar{\mathcal{B}}$ of $V/W$.
Collecting these formulas, the matrix of $A$ in the basis $\mathcal{B}$ has the block upper-triangular form
\begin{align*}
[A]_\mathcal{B} = \begin{pmatrix} [B]_{(w_i)} & A' \\ 0_{\ell \times k} & [C]_{\bar{\mathcal{B}}} \end{pmatrix},
\end{align*}
where $A' = (A'_{ij})$ is the $k \times \ell$ block coming from the $w$-components of $A(v_j)$, and the lower-left block is the $\ell \times k$ zero matrix (because no $A(w_i)$ has any $v_j$-component — this is the invariance $A(W) \subseteq W$).[/step]