Can be very tricky, I'm sure you've found the ATANFULL commands already. ATANFULL will let you work out an angle from a height and length - so the Y angle should be straightforward. If you calculate the X and Z distance,, you have a method to calculate the X angle... ATANFULL(xb-xa,dist). The Z angle is roll, which you probably wouldn't want to use, or you'd probably want to handle roll differently.
So... calculate the difference between all values...
DX#=XA#-XB#
DY#=YA#-YB#
DZ#=ZA#-ZB#
Calculate XZ distance...
DXZ#=sqrt((DX#*DX#)+(DY#*DY#))
Calculate Y angle from XZ
AY#=atanfull(dx#,dz#)
Calculate X angle from DY
AX#=atanfull(dy#,DXZ#)
This is all untested, I could make an example for you, but I think you'll figure it out regardless - it's usually just that X angle that is tricky to calculate.
The code is dark and full of errors