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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem in open excel file

Problem in open excel file

Scheduled Pinned Locked Moved ASP.NET
helpcssdesign
1 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.
  • V Offline
    V Offline
    Vinay Dornala
    wrote on last edited by
    #1

    Hi friends, Iam facing problem in opening excel file without saving into disk, Iam exporting gridview data into excel file it working file , when i open file it given missing file error, Here is the error details , can pls give suggesition why it is happening, i understood that it is because of fully qulified path missing for .CSS file in application. missing file: c\path\style.css like. here is code that i was written by me Private Sub ExportToExcel(ByVal gvInput As GridView) Dim Counter As Integer Dim dtExcel As New DataTable 'Dim dr As DataRow Dim ColNameArray As New ArrayList Dim ColPosArray As New ArrayList For Counter = 0 To gvInput.Columns.Count - 1 If gvInput.Columns(Counter).Visible Then ColNameArray.Add(gvInput.Columns(Counter).HeaderText) ColPosArray.Add(Counter) End If Next For Counter = 0 To ColNameArray.Count - 1 dtExcel.Columns.Add(ColNameArray(Counter)) Next Dim gvRow As GridViewRow Dim dr As DataRow For Each gvRow In gvInput.Rows dr = dtExcel.NewRow For Counter = 0 To ColNameArray.Count - 1 'gvRow. If gvRow.Cells(ColPosArray(Counter)).HasControls Then dr(ColNameArray(Counter)) = CType(gvRow.Cells(ColPosArray(Counter)).Controls(0), LinkButton).Text Else dr(ColNameArray(Counter)) = gvRow.Cells(ColPosArray(Counter)).Text End If Next dtExcel.Rows.Add(dr) Next Dim gvExportExcel As New GridView gvExportExcel.DataSource = dtExcel gvExportExcel.DataBind() Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("Content-Disposition", "attachment; filename=" & Now() & ".xls") Response.Charset = "" Me.EnableViewState = False Dim oStringWriter As New System.IO.StringWriter() Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter) 'Me.ClearControls(gv) gvExportExcel.RenderControl(oHtmlTextWriter) Response.Write(oStringWriter.ToString()) Response.End() End Sub Thanks in Advance,

    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