I mean, this is the type of question that is more suited for a google search than an AskScience question. See for example:
They are semiconductors with a band gap that absorb photons to create an electron-hole pair which are then separated and swept to opposite ends of the device (due to their different charges) and collected at metal contacts. The sweeping is accomplished by a built-in electric field due to a pn-junction.
If you have a more specific question you can ask but beyond that I'd send you to the enormous bounty of introductory sources freely available on the internet.
For silicon or perovskite solar-electric panels the process works approximately like this:
Photon comes in and hits the material. This puts an electron into a mobile, excited state in the material, and leaves a hole behind. The electron-hole pair is separated by an electric field (either p-n junction or ferroelectric material, mostly). Now you just have to recombine your electrons through a long wire. At this point the panel provides dc electricity with a fixed maximum voltage.