how grid tie invertor works?
From the point of view of dumping a relatively small amount of power onto the grid, the grid voltage doesn't change.  In other words, it's always going to be (ideally) a 60 Hz (here in North America) sine wave with peaks up to 170 V or so regardless of what you do to it.  "The grid" is such a low impedance voltage source that nothing you do is going to change it.

Since the inverter can't effect the voltage, the only choice it has is what current to dump onto or take off the grid at any moment.  Grid-tie inverters do this by monitoring the grid voltage, then producing a current proportional to it instance by instance.  This is nowadays done with a switching power supply usually driven by a microcontroller.  The switcher pulses at many times the grid frequency.  For each pulse, the micro measures the grid voltage and other parameters in the system and calculates how much charge to dump onto the grid for that pulse.  It is doing this 1000s of times per line cycle, so the line voltage is effectively constant during any one pulse.