When the light from the sun hits a solar panel, the absorption of light raises an electron to a higher energy state. Then, the movement of this higher energy electron creates the electric field.
When sunlight hits a solar cell, also known as a photovoltaic cell - meaning“light” and voltaic meaning “electricity” ,which energy can be transformed into an electric current. This influx of energy knocks loose electrons from the silicon atoms, allowing them to move freely.