The work done is the shaded area

This situation provides an example of the conservation of energy without the inclusion of heat.

Work is done on the spring and equivalent energy is stored in the spring.