Electricity is produced from solar cells primarily through the photovoltaic effect, not directly from light's electric and magnetic fields. When photons hit electrons in a material's valence band, they can gain energy to move to the conduction band. This movement allows the electrons to migrate toward a junction and enter a different material. A potential difference facilitates the flow of these electrons into the second material, generating electricity. This process effectively converts light energy into electrical energy in solar cells.