Google Mobile Ads

Monday, August 22, 2016

EPPlus ile oluşturulmuş excel dosyanın download edilmesi

pck EPPlus package nesnesidir. Aşağıdaki kod try-catch bloğu içerisinde olmalıdır ve ThreadAbortException hatası kesinlikle handle edilmelidir.

            Response.Clear()
            Dim timestamp As String = Request.QueryString("timestamp")
            timestamp = CodeHelper.CheckClientContent(timestamp)
            Dim fileName As String = "File_" & timestamp & ".xlsx"

            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            Response.AddHeader("Content-Disposition", "attachment;filename=" & fileName)

            Using myMemoryStream As New MemoryStream
                pck.SaveAs(myMemoryStream)
                myMemoryStream.WriteTo(Response.OutputStream)
                Response.Flush()
                Response.End()

            End Using

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...