Herst-
I've also looked into the problem before. The main issue is that unless the cog and chainring are the same size, neither is wrapped 180 degrees by the chain. It ends up breaking down to an extremely complex system if you want to get it right. I'm not even convinced that there's an analytical solution. It may have to be broken down into a linear system, but I'm not entirely sure yet. I haven't counted all my "unknowns". you'd probably have to solve a generalized linear system (I think I'd suggest gauss-jordan method for this) before getting your equations to put into your spreadsheet.
I haven't gotten that far yet... and now you have me working on it again too!
I'll see what I come up with...