they'd fit, but the overall diameter would be smaller. The 45 and 40 part mean the height of the sidewall as a percentage of the width (which is the 215).
Thus, the tires are 215mm wide. The 215/45s are 96.75mm high, and the 215/40s are 86mm high, or roughly 1 cm less high.
The 17" is the part that tells you they fit a 17" wheel.