A typical solar installation is grid-tied, meaning it does not operate independently from the grid, and a building with solar will use the power from the solar, and supplement it, as needed, with Utility grid power.
In some cases, the solar array may produce more more power than is needed in the building at certain times of day. In that case, the excess energy is put on the grid and the utility will credit the utility bill for the retail rate for that power supplied. This is called net metering.