If a spectrograph of the sun is taken with the photosphere blocked out as during a total eclipse, these same lines are seen in emission. The pattern of frequencies and intensities of spectral lines identify specific atoms or ions just as a particular finger print is unique to a person. Light undergoes Doppler shifting of frequency when there is a relative velocity between source and observer along the line of sight.
Atomic excitation can occur in all phases of matter.
In solids and liquids nearest neighbor distances are much smaller than in the gas phase and interatomic interactions are much stronger. The broadening is so strong in solids that the emission spectra merge producing the continuous spectra of hot bodies. This is a particular example of question 14. A solid tungsten filament produces the continuous spectrum characteristic of all hot bodies. Tungsten in a gaseous form can be excited to produce its characteristic line spectrum.