Despite working hard, he still failed the exam. It was too hard for him.
Despite working very little, he still passed the exam. It was easy for him.
Despite + noun phrase or gerund phrase which defines something which makes no difference to the situation in the main clause.
He wasn't lazy. To / on the contrary, he was the hardest-working student in the class. (opposite)
This is a complete phrase and is followed by a comma