Within the framework of quantum statistical mechanics, we have proposed an exact analytical solution to the problem of Bose-Einstein condensation (BEC) of harmonically trapped 2D ideal photons. We utilize this analytical solution to investigate the statistical properties of ideal photons in a 2D dye-filled spherical cap cavity. The results of numerical calculation of the analytical solution agree completely with the foregoing experimental results in the BEC of harmonically trapped 2D ideal photons. The analytical expressions of the critical temperature and the condensate fraction are derived in the thermodynamic limit. It is found that the 2D critical photon number is larger than the 1D critical photon number by two orders of magnitude. The spectral radiance of a 2D spherical cap cavity has a sharp peak at the frequency of the cavity cutoff when the photon number exceeds the critical value determined by a temperature.