This is a migrated thread and some comments may be shown as answers.

Can I cancel Export to excel in OnExporting event ?

1 Answer 135 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Hemant
Top achievements
Rank 1
Hemant asked on 08 Jan 2018, 03:01 PM

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.
}

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 09 Jan 2018, 03:54 PM

Hello,

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: https://www.telerik.com/blogs/how-to-export-grid-to-pdf-file-and-show-the-result-using-the-window. RadTreeList does not offer a built-in feature that will cancel the export or otherwise change the response again.

Regards,

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.
Tags
TreeList
Asked by
Hemant
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or