Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: How do I send data to excel and then refresh aspx page?

$
0
0
I have a gridview that the user can select rows from to export that data to excel. After they select the rows they want to export they press a button. After I export the data to the spread sheet I want my page to refresh. I rebind my gridview to nothing to clear it out, but my page is not getting refreshed.

Any ideas?

Here is my code to put the datatable that I extracted from the gridview to excel ...
 Dim wb As New ClosedXML.Excel.XLWorkbook()
 wb.Worksheets.Add(dt, dt.TableName.ToString)
 Response.Clear()
 Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  Response.AddHeader("content-disposition", "attachment;filename=MasterCredReport.xlsx")
  Using memoryStream As New MemoryStream()
          wb.SaveAs(memoryStream)
          memoryStream.WriteTo(Response.OutputStream)
          memoryStream.Close()
  End Using

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>