Can I cancel Export to excel in OnExporting event ?

2 posts, 0 answers
  1. Hemant
    Hemant avatar
    3 posts
    Member since:
    Jul 2010

    Posted 08 Jan Link to this post

    Hi ,

    In the OnExporting event I want to save the file and then cancel the exporting process , I mean I don't want user to download the file anymore.

    protected void  XyzTree_Exporting(object sender, TreeListExportingEventArgs e)

              // here I need to know the name of the file that Telerik as given to the file.  eg. "BOM Export of p046_Page1_20180108200522338.xls"
               string path = Server.MapPath("~/MyFile.xls");
               using (FileStream fs = File.Create(path))
                     Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
                     fs.Write(info, 0, info.Length);
               // this is where I want to stop the export process , As I have saved the file already.


  2. Marin Bratanov
    Marin Bratanov avatar
    4370 posts

    Posted 09 Jan Link to this post


    A general approach would be to use Response.Redirect() to change the response from the file to a redirect header. You can see a similar example here: RadTreeList does not offer a built-in feature that will cancel the export or otherwise change the response again.


    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top