This cabinet appears to have a trapezoidal footprint, and the 40" is across the back (widest part).
If the front is 32" across, then you still have (essentially) a 36 x 22 horizontal space. (y)
Lighting is going to be a challenge, but with planning, can be done. Plants that require full sun...