For any solar cell operation you require following:
1. A material which can absorb light in order to generate electron hole pair, more precisely charge carriers. Variety of semiconductors are known to full fill this condition and silicon is one of those material.
2. Spacial separation of generated electrons and holes before their recombination.
3. Collection of different type of photogenerated charge carriers (generated because of absorption of photon) at different contact in order to give net current in the circuit if two terminals are connected via load resistance.
When pn junction is formed from crystalline silicon, an electric field and depletion region is developed near the metallurgical junction. When you incident a photon of energy greater than band gap energy it will generate electron hole pair in the device. If generated electron hole pair are in depletion region they will be separated from each other in space because of electric field in depletion region. Because of electric field electron then goes to n type material and hole goes to p type material and eventually they will be collected at the respective contact. You can see direction of flow of charge in this case is opposite to what was supposed in the forward bias pn junction. So you can say your current is negative and you are getting -ve current out of the device without any biasing potential.
Now if you will forward bias the pn junction then your current will start decreasing (in magnitude) and it will be zero at some applied bias. That bias is known as open circuit potential of the cell and the current at no bias known as short circuit current of the cell. At any point between short circuit condition and open circuit potential if you will calculate the electric power you will get -ve value (+ve potential and -ve current) which says that you are not dissipating electric power in the device while you are getting some power out of it.
What if generation is not in the depletion region? Now that is very simple. If generation is within the diffusion length from the edge of depletion region those carriers are likely to go to the depletion region and contribute to photocurrent. While if the generation is away from diffusion length those carriers are likely to recombine before they reach the depletion region and doesn't contribute to photocurrent.
This was the basic concept of solar cell. If you want to know more detail you can go through the website: