We study exclusive charmonium production in diffractive deep inelastic scattering and ultra-peripheral heavy-ion collisions within the dipole picture. The mass spectrum and light-front wavefunctions of charmonium are obtained from the basis light-front quantization approach, using the one-gluon exchange interaction plus a confining potential inspired by light-front holography. We apply these light-front wavefunctions to exclusive charmonium production. The resulting cross sections are in reasonable agreement with electron-proton collision data at HERA and ultra-peripheral nucleus collision measurements at RHIC and LHC. The charmonium cross-section has model dependence on the dipole model. We observe that the cross-section ratio of excited states to the ground state has a weaker dependence than the cross-section itself. We suggest that measurements of excited states of heavy quarkonium production in future electron-ion collision experiments will impose rigorous constraints on heavy quarkonium light-front wavefunctions, thus improving our understanding of meson structure, which eventually will help us develop a precise description of the gluon distribution function in the small-$x$ regime.