Diet is far more important.
As far as I have read, metformin slows down the amount of sugar your liver produces but does nothing against what you eat, so diet is the key. Exercise does help as well of course, but I believe diet is the most important thing.
Note: I'm T1 and don't take metformin so that is what I'm led to believe by reading various posts about metformin.