Spectral reflectance or transmittance measurements provide intrinsic information on the material of an object and are widely used in remote sensing, agriculture, diagnostic medicine, etc. Most reconstruction-based spectral reflectance or transmittance measurement methods based on broadband active illumination use narrow-band LEDs or lamps combined with specific filters as spectral encoding light sources. These light sources cannot achieve the designed spectral encoding with a high resolution and accuracy due to their low degree of freedom for adjustment, leading to inaccurate spectral measurements. To address this issue, we designed a spectral encoding simulator for active illumination. The simulator is composed of a prismatic spectral imaging system and a digital micromirror device. The spectral wavelengths and intensity are adjusted by switching the micromirrors. We used it to simulate spectral encodings according to the spectral distribution on micromirrors and solved the DMD patterns corresponding to the spectral encodings with a convex optimization algorithm. To verify the applicability of the simulator for spectral measurements based on active illumination, we used it to numerically simulate existing spectral encodings. We also numerically simulated a high-resolution Gaussian random measurement encoding for compressed sensing and measured the spectral reflectance of one vegetation type and two minerals through numerical simulations. We reconstructed the spectral transmittance of a calibrated filter through an experiment. The results show that the simulator can measure the spectral reflectance or transmittance with a high resolution and accuracy.