On the basis of ab initio molecular orbital calculations, we have derived 12-1-3 potential functions for interaction between formaldehyde, in both the ground and the n-pi* singlet excited state, and one water molecule as well as the transition dipole moment functions in the n-pi* transition of formaldehyde interacting with a water molecule. Using these functions, we carried out simulations of vibrational structures in the n-pi* absorption spectrum of formaldehyde complexed with a few water molecules (n = 1-3) and in water solution. Detailed analyses of structural and energetic features have been carried out. Formaldehyde in cluster interacts with the chain of hydrogen-bonding water molecules, while formaldehyde in water solution is surrounded by water molecules. Water molecules around the oxygen atom of formaldehyde interact attractively and those around the hydrogen atoms of formaldehyde interact both attractively and repulsively with formaldehyde. Though the transition energy shift in the H2CO-3(H2O) cluster does not reach that in water solution, the bandwidth of the simulated absorption spectrum in the H2CO-3(H2O) cluster is nearly the same as that in water solution.