Much is made of canonization of Saint Mary MacKillop with her sordid past of being an ex-communicated Catholic.
Whether by ex-communicated we mean official ecclesiastical punishment or a punishment imposed by a religious superior. One’s being cut off from the Christian community sacramentally is strikingly painful but sometimes a needed medicine for the cure of some spiritual sickness typically demonstrated in an act of disobedience to the Church’s authority based on intellectual separation from some dogma or doctrine of the Church. You’ll see this with matters pertaining to abortion and certain healthcare matters. One simple example is that the medicine of excommunication is automatically imposed by the act itself for threatening the life of the pope. For more information see Book VI of the 1983 Code of Canon Law, canons 1364-99 outline
Some good examples of saints who were once excommunicated and then restored to communication in the Church are:
Saint Hippolytus of Rome
Saint Joan of Arc
Saint Gerard Majella – by St Alphonsus Liguori
Saint Mary of the Cross MacKillop – by the bishop in Australia
Saint Theodore Guerin by her bishop