When a force stretches a spring, it does work on the spring and energy is transferred to it. The work done is equal to the energy transferred. If the spring is not stretched beyond its elastic limit, this energy is stored as elastic potential energy and is released when the spring returns to its original length.
For a spring in the linear case, energy transferred = one half × spring constant × extension squared, or E = ½ × k × e2. The energy is in joules (J), the spring constant is in N/m and the extension is in metres. Square the extension first, then multiply by k, then halve. For example, a spring with k = 300 N/m is stretched by 0.2 m. The extension squared is 0.04, so E = 0.5 × 300 × 0.04 = 6 J. Because the extension is squared, doubling the extension makes the energy stored four times bigger.
The work done is also equal to the area under the force-extension graph. For a straight line this area is a triangle, with area ½ × extension × force. For a curved graph, such as the one for an elastic band, you can count the squares under the curve to estimate the work done.