Gas excitation in galaxies and active galactic nuclei with He IIλ4686 and X-ray emission