What are solar panels? Typically, they are rectangular or square, plate-like structures made up of silicon cells. These cells are a form of semiconductor and contain electrons. Chemical substances are applied to the cells (such as phosphorous and boron) to create a magnetic field. Some of the cells have a positive charge and some have a negative charge. When the sunlight shines on the cells, it destabilizes the electrons. The negatively-charged electrons are freed and flow to one side of the silicon cell. This movement produces an electrical current. Metal conductors on the cell gather this electricity and transfer it to wires and batteries.
Resource: modernize.com/solar/how-do-solar-panels-work and voltronicpower.com