I am able to make colours for the all rows but, I want to do conditional formatting for totals and subtotals, how do I achieve this?
This is currently not possible. You can only hardcode colors for totals.
I can mark it as a feature request.