The explosion took place at the Dongtun Fireworks Factory in Huaiyang county, local government said.
Five workers were killed on the spot and two others died at hospital.
Twelve people were also injured in the accident.
At the time of the blast, the workers were being involved in illegal production as the factory had been ordered to suspend production since its license has expired, Xinhua news agency reported.
Police detained the factory owner's family as he was reportedly on a business tour.
The county authorities have ordered all local fireworks factories to suspend production to fix safety loopholes.