Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1000
DownloadName does not preserve '_' in the file name.
posted

Hi,

I have a strange problem, when I specify a DownloadName that contains '_' character it gets stripped out when the excel document has been generated and presented for download. Also the character length is limited.

exp1.DownloadName = "Control_Acceso_Denegado_" & String.Format("{0:yyyyMMddHHmmss}", DateTime.Now) & ".xls"

 

The following DownloadName returns: ControlAccesoDenegado20091113.XLS

Is this a bug?

 

 

Parents
No Data
Reply
  • 4960
    Verified Answer
    posted

    Since this filename appears in the HTTP headers sent to the client, it was designed in such a way as to be Secure by Default if the download name is something user- or third party-supplied.  It enforces constraints on the DownloadName and WorksheetName properties that are very restrictive.

    What you can do is implement your own name validation, using the NameValidating event on the exporter control.  See NameValidatingEventArgs for an overview.

    In the most trivial case when you know the filename you are giving the Excel workbook is safe, the following event handler sidesteps this validation.  It approves whatever name you have assigned to DownloadName,

    void ExcelExporter1_NameValidating( object sender, NameValidatingEventArgs args)
    {
       args.ApprovedName = args.ProprosedName;
    }

     

Children