Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!

 

I use this code to export the contents og a gridview to MS Excel:

 

Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click 

Response.Clear()

Response.AddHeader("content-disposition", "attachment;filename=FileName.xls") 

Response.Charset = "" 

' If you want the option to open the Excel file without saving than 

' comment out the line below 

' Response.Cache.SetCacheability(HttpCacheability.NoCache); 

Response.ContentType = "application/vnd.xls" 

Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter() 

Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite) 

GVInsert.RenderControl(htmlWrite)

Response.Write(stringWrite.ToString())

Response.End()

End Sub 

 

This works fine, but my norwegian lettes, æ, ø and å is messed up...

 

I guess i might have something to do with the charset, but i don't know what...

 

 

noccy

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...