Ab initio calculation of excitonic effects in realistic materials