In that case,

if you have to use spearmen on the attack, here are two things that can help.

1: Use them to pin an enemy unit, then do a flank attack on the same enemy unit with one of your non-spear units. This can be a good way of neutralizing a powerful enemy unit.

2: Sometimes if you stop a spear unit a little in front of an enemy, you get time for your spears to regroup, and the enemy attacks. So you get to use your rank bonus even on the offensive.