The presence of harmonic and inter-harmonic components in grid voltage and current signals produces energy that variably impacts different electrical devices, making it imperative to meter these components separately. This paper begins by categorizing the electrical energy generated from grid voltage and current signals into four distinct types, including fundamental, harmonic, inter-harmonic, and cross terms. Subsequently, the interpolation factor of the measurement matrix, constructed using the Dirichlet kernel, is adjusted to enhance the resolution of voltage and current spectra obtained through fast Fourier transform (FFT). Furthermore, a Bayesian compressive sensing (BCS) reconstruction algorithm is employed to estimate the frequency, amplitude, and initial phase angle of all different frequency components present in the grid voltage and current signals. This is followed by a time-domain reconstruction of each frequency component, leading to the calculation of the four types of partitioned electrical energies. Simulation tests are conducted to validate the performance. The results demonstrate that, in scenarios including inter-harmonic components, the proposed algorithm enhances spectral resolution without prior knowledge of the number of frequency components in voltage and current, thereby providing higher measurement accuracy and improved applicability compared to conventional methods commonly used in the field.