We consider the one-dimensional partially asymmetric exclusion model with open boundaries. The model describes a system of hard-core particles that hop stochastically in both directions with different rates. At both boundaries particles are injected and extracted. By means of the method of Derrida, Evans, Hakim and Pasquier the stationary probability measure can be expressed as a matrix-product state involving two matrices subject to a quadratic algebra. We obtain the representations of this algebra and use the two-dimensional one to derive exact expressions for the density profile and correlation functions. Using the correspondence between the stochastic model and a quantum spin chain, we obtain exact correlation functions for a spin-$\frac{1}{2}$ Heisenberg XXZ chain with non-diagonal boundary terms. Generalizations to other reaction-diffusion models are discussed.