An excommunication is intended to shock the sinner into repentance. Some sins are so grievous in their very object that they warrant an automatic excommunication. Violating the seal of Confession, for example, is one of those sins. To be accepted back into communion after an excommunication, one must do special penance in order to be received again. Of course, much has changed on this topic over the long history of the Church. Excommunications just don’t happen anymore. I, personally, would like to see them make a comeback in order to shock people into repentance, with the entire community there to participate.
I probably would repent.