The problem with the ranger spells and the whirlwind attack (from a RAW perspective, most definitely not a balance one) is that the swarms immunity is typed as "damage from weapons".
Even though you could pepper the area like you're shooting a 2-guage shotgun, they're immune to the pellets.
But otherwise, I agree with Stream. It should work like that. It just requires a house-rule to do so. Ask your DM.
EDIT: yeah, ask your DM. If he refuses that house-rule, find a new DM.