This paper reports a compact spectrometer based on a guided-mode resonance (GMR) filter mounted on a linear charge-coupled device (CCD). The GMR is specially designed to exhibit gradient grating periods (GPPs) laterally to ensure that the GMR functions as a linear-variable bandstop filter. Each period corresponds to a resonant wavelength such that this wavelength is reflected back at its corresponding resonant period and transmitted to all other periods. Consequently, when a resonant wavelength is incident on the GGP-GMR attached to a linear CCD, the CCD pixel underneath its resonant period receives the minimum intensity, and the other pixels receive higher intensities. In terms of the wavelength range of interest, by scanning a single wavelength at a time, a transmission efficiency matrix that contains the transmission efficiency of each wavelength at each pixel can be established. An unknown incident spectrum can be reconstructed using the established transmission efficiency matrix and the intensity measured using the CCD. In this study, a GGP-GMR spectrometer less than 3 mm long that can achieve a wavelength detection range of 200 nm was demonstrated to reconstruct various incident spectra, including a single wavelength of light with a resolution of 0.5 nm, a single wavelength of light with varying intensity levels, and dual incident light sources.