Currently taking the curve to salvation strategy:
Use MVC .....
<Dx:aspxgridviewID= "ASPxGridView1"runat= "Server"AutoGenerateColumns= "False"DataSourceID= "SqlDataSource1"Keyfieldname= "Friendlinkid"Theme= "Default"enabletheming= "True"> <Columns> <Dx:gridviewdatatextcolumnFieldName= "Friendlinkid"ReadOnly= "True"Visibleindex= "0"> <editformsettingsVisible= "False" /> </Dx:gridviewdatatextcolumn> <Dx:gridviewdatatextcolumnFieldName= "Linkname"Visibleindex= "1"> </Dx:gridviewdatatextcolumn> <Dx:gridviewdatatextcolumnFieldName= "Linksrc"Visibleindex= "2"> </Dx:gridviewdatatextcolumn> <Dx:gridviewdatatextcolumnFieldName= "Contact"Visibleindex= "3"> </Dx:gridviewdatatextcolumn> <Dx:gridviewdatadatecolumnFieldName= "Publishdata"Visibleindex= "4"> </Dx:gridviewdatadatecolumn> </Columns> </Dx:aspxgridview> <Asp:sqldatasourceID= "SqlDataSource1"runat= "Server"ConnectionString= "<%$ connectionstrings:pengbg_dataconnectionstring%>"SelectCommand= "SELECT * FROM [Friendlink]"></Asp:sqldatasource> <Dx:aspxgridviewexporterID= "ASPxGridViewExporter1"Gridviewid= "ASPxGridView1"runat= "Server"></Dx:aspxgridviewexporter> <Asp:buttonID= "Button1"runat= "Server"Text= "button"OnClick= "Button1_Click" />
protected voidButton1_Click (Objectsender, EventArgs e) { varFileName =NewRandom (). Next (). ToString (); varFullPath =@"C +"+ FileName +". xls"; using(varFS =NewFileStream (FullPath, FileMode.CreateNew, FileAccess.Write)) {Aspxgridviewexporter1.writexls (FS); } Response.Redirect ("default1?path="+FullPath); }
Public classDefault1controller:controller {// //GET:/default1/ PublicActionResult Index (stringpath) {String NewFileName= DateTime.Now.ToString ("YYYYMMDDHHMMSSFF"); returnFile (path), System.IO.File.ReadAllBytes"Application/vnd.ms-excel", Httputility.urlencode (string. Format ("{0}.xls", NewFileName))); } }
Principle in speculation, debugging ...
DevExpress ASP. NET export Excel automatically turns on Thunder problem, save as ASPX page by default