How could an excommunicated person possibly validly vote or be elected? It's a requirement for both to be a Catholic.
"No Cardinal can in any way be excluded from the active and passive election of the Supreme Pontiff on the pretext or by reason of any excommunication, suspension, interdict, or other ecclesiastical impediment whatsoever; We, in fact, suspend these censures only for the effect of an election of this sort; they will remain in their own force in other circuмstances....
...After this agreement has been furnished within a time limit to be determined by the prudent judgment of the Cardinals by a majority of votes (to the extent it is necessary), the man elected is instantly the true Pope, and he acquires and can exercise full and absolute jurisdiction over the whole world." - Pope St. Pius X, Vacantis Apostolicae Sedis