An electric surgical stapler and a method for controlling closing and firing of the electric surgical stapler are disclosed. The electric surgical stapler includes: a driving motor, having an output shaft; a working head, including an anvil, a cartridge, a closing mechanism, a firing mechanism, a closing limit switch, and a firing safety switch, wherein the closing limit switch is configured to detect a closing stroke of the closing mechanism, the firing safety switch has a closing position and a firing position, the firing safety switch is configured to allow the output shaft to transmit power to the closing mechanism when the firing safety switch is at the closing position, and the firing safety switch is configured to allow the output shaft to transmit power to the firing mechanism when the firing safety switch is at the firing position; and a control unit, including: a working head identifying module; a motor control module; a closing and firing control module, configured to receive information transmitted from the closing limit switch and the firing safety switch; a closing switch; and an opening switch. The control unit is provided with a plurality of modules, and is able to communicate with the working head in real time, to avoid abnormal or fault operations during surgery, and to improve security in use.