More robust XLS export code.