A solar cell is made from layers of silicon. Silicon is an excellent semi-conductor with 4 balanced electrons. A semi-conductor will only permit the movement of energy (electrons) in certain conditions (when light energy is absorbed).
The top layer of silicon is mixed with a small amount of an element such as phosphorus. Phosphorus has 5 electrons. This mix creates an excess of electrons that are free to move and makes the silicon mix more conductive. The bottom layer of silicon is mixed with an element such as boron, with 3 electrons. The top layer has an effective negative charge.
When light energy, or photons, are absorbed by the silicon mix, they agitate the free electrons in the negatively charged layer, which are then free to travel to the electron holes create by the effective positive charge of the silicon layer mixed with boron.
This movement of electrons creates and electric field, or voltage. The top of the cell is imprinted with a metal grid, such as silver, whilst the bottom layer is imprinted with a metal plate, such as aluminium. These two metals act as electrodes, creating a flow of electrons, which we know as voltage.