If you can figure out how to accurately calculate an APR using excel, then you are better than most people. I have never seen an Excel product that was accurate.
All of the math is spelled out in Appendix J of Reg. Z. It's not simple. There is a general equation and several special variations, however in all cases the solution is rendered by the process of iteration.