Anatomy of a Solar Cell
Before now, the two separate pieces of silicon were electrically neutral; the interesting part begins when you put them together. That's because without an electric field, the cell wouldn't work; the field forms when the N-type and P-type silicon come into contact. Suddenly, the free electrons on the N side see all the openings on the P side, and there's a mad rush to fill them.
Do all the free electrons fill all the free holes? No. If they did, then the whole arrangement wouldn't be very useful. However, right at the junction, they do mix and form something of a barrier, making it harder and harder for electrons on the N side to cross over to the P side. Eventually, equilibrium is reached, and we have an electric field separating the two sides.
This electric field acts as a diode, allowing electrons to flow from the P side to the N side, but not the other way around. It's like a hill -- electrons can easily go down the hill (to the N side), but can't climb up it (to the P side).When light, in the form of photons, hits our solar cell, its energy breaks apart electron-hole pairs. Each photon with enough energy will normally free exactly one electron, resulting in a free hole as well. If this happens close enough to the electric field, or if free electron and free hole happen to wander into its range of influence, the field will send the electron to the N side and the hole to the P side.
This causes further disruption of electrical neutrality, and if we provide an external current path, electrons will flow through the path to the P side to unite with holes that the electric field sent there, doing work for us along the way. The electron flow provides the current, and the cell's electric field causes a voltage. With both current and voltage, we now have DC power.