Did the two outside walls of an old sunroom and I'd say next time I'd not bother with the spray foam and just cut to fit. I used two layers of foam board to fill and left a 1/4 gap round the outer layer and spray foamed to sealed it. Had to use some 1x1 boards to hold the insulation and keep the foam from pushing it out, then trimmed the excess spray foam down with a hack saw blade.
Cut all the foam last year but finally got it all sealed up just a bit ago. The room was not sealed correctly and was a major heat leak for the house so it's always gonna be warmer than outside and not need a heater. I put one of those outside temp gauges in the room to compare and I don't think foamed it showing much diff compared to last year. Maybe when it gets colder but still not impressed for all the effort to foam seal.
For example last year it dropped to low 40's at the coldest in the room, but even in the now warmer than last year weather it's still just right at 50 now. More than warm enough for me to work in but just figured I'd share my results and see if any other has used this method.