Serial No.

I want to add serial no in a list page, i have done using an integer variable as sr no and code is written on onaftergetrecord 
sr no:= sr n0 +1;
its working 
but no changes when i do export to excel using ctrl+e or by clicking the ascending or descending arrow in list page. I m using nav 2013 r2