Pakistan's Prime Minister-in-waiting Imran Khan today tendered a written apology for violating the secrecy of the ballot, prompting the election commission to withdraw its notice to him, paving the way for his swearing-in next week.