How much work is done as the spring stretches from $20$ to $40\ \mathrm{cm}$?
$A_{total}=12\ \mathrm{J}$
The area under the curve will be equal to the work done. In this case, we have some choices. You may recognize this shape as a trapezoid (it might help to momentarily rotate your head 90 degrees) to see this.
$$A=\frac{1}{2}(b_1+b_2)h$$
$$A=\frac{1}{2}(40\ \mathrm{N+80\ N)(0.20\ m)}$$
$$A=12\ \mathrm{N\cdot m}$$
$$\mathrm{or}$$
$$A=12\ \mathrm{J}$$
An alternative choice is to recognize this shape as a triangle sitting on top of a rectangle. The total area is simply the area of the rectangle plus the area of the triangle.
$$A_{total}=A_{rectangle}+A_{triangle}$$
$$A_{total}=bh_1+\frac{1}{2}(bh_2)$$
$$A_{total}=(0.20\ \mathrm{m)(40\ N-0\ N)+\frac{1}{2}(0.20\ m)(80\ N-40\ N)}$$
$$A_{total}=8\ \mathrm{N\cdot m+4\ N\cdot m}$$
$$A_{total}=12\ \mathrm{J}$$

