Answer
See proof
Work Step by Step
$V$ = ${\pi}r^2x$
so $V$ is a function of $x$ and $P$ can also be regarded as a function of $x$ .
If $V_1$ = ${\pi}r^2x_1$ and $V_2$ = ${\pi}r^2x_2$, then
$W$ = $\int_{x_1}^{x_2}F(x)dx$ = $\int_{x_1}^{x_2}{\pi}r^2(P(V(x))dx$ = $\int_{x_1}^{x_2}(P(V(x))dV(x)$
Let $V(x)$ = ${\pi}r^2x$
$dV(x)$ = ${\pi}r^2dx$
so
$W$ = $\int_{V_1}^{V_2}P(V)dV$ by the substitution rule