Repeater exports data in Excel format to repeater1. The following is an example of how to export repeater1 content. Code System. Io. stringwriter SW = New System. Io. stringwriter ();
System. Web. UI. htmltextwriter HW = New System. Web. UI. htmltextwriter (SW );
This . Repeater1.rendercontrol (HW );
response. clear ();
response. contenttype = " application/vnd. MS-Excel " ;< br> response. charset = " " ;
page. enableviewstate = false ;
Response. appendheader ( " Content-Disposition " , " Attachment?filename=teacher.xls " );
Response. Write ( " <HTML> " Text / HTML; charset = Gb2312 \ " > <Title> copyright by SDU </title> " );
Response. Write (SW. tostring ());
Response. Write ( " </Center> </body> " );
Response. End ();
Note: When a numeric string of the simplified type is exported to excel, it is often changed to scientific notation. The solution is to bind it to repeater1:<TD Style="Vnd. ms-excel.numberformat :@"> <%# Databinder. eval (container. dataitem,"Shenfenzheng")%> </TD>