Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. problem when exporting datagrid to excel [modified]

problem when exporting datagrid to excel [modified]

Scheduled Pinned Locked Moved Visual Basic
helpdesignquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ii_noname_ii
    wrote on last edited by
    #1

    Hi, I've seen people complain about this error other places, but noone ever answers them... Can't find solution to this erro message: 'c:\documents....\...xls' could not be found. Check the selling blah blah blah (it appears in excel when clicking the send to excel button) It seems it's trying to open a file that doesn't exist yet or something... Then I can click the button on my apsx page again, and it will work fine in excel... But any help solving this problem will be very appreciated... I'm sure some of you have seen this probelm before? :s -- modified at 4:20 Monday 7th August, 2006 the code: Response.Clear() Response.Buffer = True Response.AddHeader("Content-Disposition", "attachment;filename=Wells.xls") Response.ContentType = "application/vnd.ms-excel" Me.EnableViewState = False Response.Charset = String.Empty Dim myTextWriter As New System.IO.StringWriter() Dim myHtmlTextWriter As New System.Web.UI.HtmlTextWriter(myTextWriter) Exceldg.RenderControl(myHtmlTextWriter) Response.Write(myTextWriter.ToString()) Response.End() when i remove the line Response.AddHeader("Content-Disposition", "attachment;filename=Wells.xls") it just opens the excel inside the browser without errors, so i'm guessing error is from that line for some unknown (to me) reason

    I 1 Reply Last reply
    0
    • I ii_noname_ii

      Hi, I've seen people complain about this error other places, but noone ever answers them... Can't find solution to this erro message: 'c:\documents....\...xls' could not be found. Check the selling blah blah blah (it appears in excel when clicking the send to excel button) It seems it's trying to open a file that doesn't exist yet or something... Then I can click the button on my apsx page again, and it will work fine in excel... But any help solving this problem will be very appreciated... I'm sure some of you have seen this probelm before? :s -- modified at 4:20 Monday 7th August, 2006 the code: Response.Clear() Response.Buffer = True Response.AddHeader("Content-Disposition", "attachment;filename=Wells.xls") Response.ContentType = "application/vnd.ms-excel" Me.EnableViewState = False Response.Charset = String.Empty Dim myTextWriter As New System.IO.StringWriter() Dim myHtmlTextWriter As New System.Web.UI.HtmlTextWriter(myTextWriter) Exceldg.RenderControl(myHtmlTextWriter) Response.Write(myTextWriter.ToString()) Response.End() when i remove the line Response.AddHeader("Content-Disposition", "attachment;filename=Wells.xls") it just opens the excel inside the browser without errors, so i'm guessing error is from that line for some unknown (to me) reason

      I Offline
      I Offline
      ii_noname_ii
      wrote on last edited by
      #2

      Solved it myself, posting solution for others: I had and needed this on top of my page Response.CacheControl = "no-cache" (Or it wouldn't show last added items..) Had to remove that line to get the excel thing working... And to solve the display thing, I just sent a unique new id for each time a record was added (open aaa.aspx?id="& newID &" instead of open aaa.aspx))

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups