"Unable to Open File" - excel output of Datagrid <-help needed

Discussion in 'ASP .Net' started by Steve Chatham, Feb 25, 2004.

  1. I am stuck on this. It ought to be a simple reason as to why this is
    problematic, in that it works on smaller groups of data (say under 40
    records), but doesn't on larger groups of records (40+).

    I'm displaying 9 columns in a datagrid, and have a radiobutton at the top of
    the page that says Web, Excel & Word. Web is selected by default. If you
    click one of the other two buttons, this code is executed:

    Private Sub RbtnExport_SelectedIndexChanged(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles RbtnExport.SelectedIndexChanged

    DataGrid1.AllowSorting = False

    RbtnExport.Visible = False

    btnReset.Visible = False

    btnReports.Visible = False

    Response.Charset = ""

    EnableViewState = False

    Dim sFile As String = Session("User") & "-Product List-" & Today()

    sFile = sFile.Replace("/", "")

    RbtnExport.Visible = False

    Select Case RbtnExport.SelectedItem.Value

    Case "Excel"

    Response.ContentType = "application/vnd.x-msexcel"

    Case "Word"

    Response.ContentType = "application/msword"

    End Select

    Response.AddHeader("Content-Disposition", "Attachment; filename=" & sFile &
    ".xls")

    btnReset.Visible = True

    btnReports.Visible = True

    RbtnExport.Visible = True

    DataGrid1.AllowSorting = True

    EnableViewState = True

    End Sub

    The smaller datagrids display fine, but anything more than 40 records
    (approx 1K per record), doesn't work. When I save the file, it saves as
    whatever.xls, and on a File/Open or a double click, it'll give me an "Unable
    to read file." message and an OK box in Excel. You click on OK, and nothing
    is loaded.

    Small (20-30 records) files (approx 25K) work fine. I do nothing any
    different in displaying a 75 record file than I do here, but Excel simply
    will not open it.

    I have tried several other options, looking at aspone.excel, and also trying
    the render html option but that doesn't work - I get an error about a
    control being outside a form or something. I even tried a component that
    did all that, and all it would ever return is a blank page.



    I am at the end of my rope on this one. Would appreciate any help.

    SC
     
    Steve Chatham, Feb 25, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Vinokur
    Replies:
    2
    Views:
    434
    Kevin Goodsell
    Aug 20, 2003
  2. spidey12345
    Replies:
    2
    Views:
    418
    spidey12345
    Feb 8, 2007
  3. mariox

    Fatal: Unable to open file 'WS2_32.OBJ'

    mariox, Oct 17, 2004, in forum: C Programming
    Replies:
    1
    Views:
    774
    Mark McIntyre
    Oct 18, 2004
  4. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,597
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  5. Ryan Macy

    Ideas needed & help needed!

    Ryan Macy, Jul 19, 2006, in forum: Ruby
    Replies:
    2
    Views:
    543
    Ryan Macy
    Jul 19, 2006
Loading...

Share This Page