In the heterogeneous networks (HetNets), finite spectrum resources limit the improve of network performance. Increased energy consumption also draws attention to the green communications. In this paper, we study the resource allocation and energy management problem for orthogonal frequency division multiple access (OFDMA)-based HetNets powered by hybrid energy, i.e. renewable energy and on-grid energy. To achieve the fairness among small cell BSs (SBSs) and also improve spectrum utilization, SBSs can share their own spectrum bands to others. To tackle the time-varying events in networks, we use Laypunov optimization method to develop an online dynamic control algorithm (ODCA), whose objective is to maximize the transmission and sharing profits with the least grid energy consumption. The proposed algorithm decompose the problem into three sub-problems: admitted rate control, resource allocation, and energy management. In the resource allocation sub-problem, we first establish a two-SBS bargaining problem to achieve the spectrum sharing and then extend it to a multiple-SBS bargaining problem. Simulation results are presented to demonstrate the effectiveness of the proposed scheme.