TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Senorita
1.6k
123
8.7k
Export .xlsx from Gridview in vb.net using asp.net
Nov 14 2019 10:18 PM
hi i am trying to export gridview data in xlsx file using below code, but when i open file its showing error,
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=Report.xlsx")
Response.Charset = ""
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
For Each r As GridViewRow In GridView1.Rows
If r.RowType = DataControlRowType.DataRow Then
For columnIndex As Integer = 0 To r.Cells.Count - 1
r.Cells(columnIndex).Attributes.Add("class", "text")
Next
End If
Next
GridView1.RenderControl(htmlWrite)
Dim style As String = "<style> .text { mso-number-format:\@; } </style> "
Response.Write(style)
Response.Write(stringWrite.ToString())
Response.[End]()
Reply
Answers (
7
)
Asp Core Cascade Drop Down List without using Entity framewo
Intellisense Not Working on vs2019