Excitation and ionization of helium in the solar atmosphere