We study the ranks of commutators and generalized semicommutators of Toeplitz operators with quasihomogeneous symbols on both the harmonic Bergman space and the Bergman Space. In particular, when one of quasihomogeneous symbols is the the form of $e^{ik\theta }r^{m}$, we first obtain specific sufficient and necessary conditions for commutators and generalized semicommutators to be finite rank. Then we make further efforts to determine the range of each finite rank commutator and generalized semicommutators, and consequently the explicit canonical form and the rank are obtained. Thus, the finite rank problem of commutators and generalized semicommutators of such special Toeplitz operators is completely solved. As applications, several interesting corollaries and nontrivial examples are given. Also, we show close connections of the finite rank problem between the harmonic Bergman space and Bergman space cases.