• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "ASP.NET Excel Export"

Collapse

  • Durbs
    replied
    Will have a play with that. Used that carlosag site before for his charting component which is fairly basic but does a nice job and is also free. The guy obviously knows his stuff!

    Leave a comment:


  • DimPrawn
    replied
    Have a look here. I'm using this (albeit on 1.1) and it works a treat.

    http://forums.contractoruk.com/thread6725.html

    Leave a comment:


  • Durbs
    replied
    Nah, still the same. Cant understand it, it just ignores the data sent to the function and writes the entire page to Excel.

    Going to have to look into the XML route instead for this one i think.

    Leave a comment:


  • Durbs
    replied
    Yes, i am using a master page in this instance, hadnt thought of that one, will give it a go with a non master page'd site and see what happens.

    Leave a comment:


  • Durbs
    started a topic ASP.NET Excel Export

    ASP.NET Excel Export

    This is doing my nut in. I've got a simple function that i've used countless times in VS 2003 .net 1.1 projects to export a dataset to Excel.

    When i use this function in Visual Web Developer .net 2.0 projects though it exports the whole HTML page to excel, not just the supplied dataset.

    The function is:

    Code:
    Sub ConvertToExcel(ByVal ds As DataSet, ByVal response As HttpResponse)
    
            response.Clear()
            response.Charset = ""
            'set the response mime type for excel
            response.ContentType = "application/vnd.ms-excel"
            'create a string writer
            Dim stringWrite As New System.IO.StringWriter
            'create an htmltextwriter which uses the stringwriter
            Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
            'instantiate a datagrid
            Dim dg As New DataGrid
            'set the datagrid datasource to the dataset passed in
            dg.DataSource = ds.Tables(0)
            'bind the datagrid
            dg.DataBind()
            'tell the datagrid to render itself to our htmltextwriter
            dg.RenderControl(htmlWrite)
            'all that's left is to output the html
            response.Write(stringWrite.ToString)
            HttpContext.Current.ApplicationInstance.CompleteRequest()
    
        End Sub
    And is called from the page like: ConvertToExcel(YourDatasetName, Response)
    tied to a buttons onclick event (plus code to generate dataset 'YourDatasetName').

    Anyone know why this doesnt just export the dataset (it'll also export any text or images on the page that contains the button) or does anyone have a decent alternative .net 2.0 VB example as simple as this one?

    Ta.
Working...
X