We prove the existence of a complete asymptotic expansion of the spectral function (the integral kernel of the spectral projection) of a Schrödinger operator H=-Δ+b acting in Rd when the potential b is real and either smooth periodic, or generic quasiperiodic (finite linear combination of exponentials), or belongs to a wide class of almost-periodic functions.