Wrong file name encoding when exporting Telerik report to PDF or XLS

4 posts, 0 answers
  1. Guillaume
    Guillaume avatar
    7 posts
    Member since:
    Jul 2012

    Posted 12 Feb 2013 Link to this post

    Hello,

    I have an issue with the name of the generated files when exporting a report to PDF or XLS from the report viewer. When a report contains a "special character" (for example "ä") in its name the character in question is not rendered correctly when clicking on the "Export" link. Instead I have a question mark wrapped in a black losange.

    I understand this issue is related to URL encoding but I'm not sure how to handle it. Here's my scenario with more details:

    Environment information:
    - Silverlight 4.0
    - IIS 7.0
    - IE 8.0
    - Telerik Reporting 2012Q1

    In our Silverlight 4 application, a user wants to create a report. At first, he is on a page (a FloatableWindow) on the application and clicks on a button. This button sends the user to the ASPX page handling the report generation. The click on the button actually calls HtmlPage.Window.Navigate with the URI of the ASPX page in question and a bunch of parameters we use to generate the appropriate report. Among these parameters, one corresponds to the name the report will be given (also used as the file name which the report will be generated to). When debugging, in the ASPX page, I can see that the name of the report is correctly encoded (ie. the character "ä" is present and displayed correctly in the report name). The report is generated correctly in the report viewer but when clicking on the "Export" link (to PDF or XLS, same behavior), the name of the file does not hold this character anymore but instead the question mark with the black losange. Below are some code extracts that may help on our process.

    Code-behind of the ASPX page holding the ReportViewer:

    public class ReportManagementPage : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Report report = new MyReport();
            report.Name = Request.QueryString["reportName"];
            report.DocumentName = Request.QueryString["reportName"];
      
            reportViewer.Report = report;
        }    
    }

    The above code correctly assigns the report name and document name correctly encoded. Clicking on Export does not use the correct encoding. If I right-click on "Export" and select "Open in new tab", the URL in the URL box of IE looks fine but the title of the page (in the tab and in the browser) uses the wrong encoding. FYI, spaces are correctly rendered and do not use %20, not even in the URL. Is there any way to fix this and tell the "Export" link/button what encoding to use for the file name?

    Thanks for your help.
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 15 Feb 2013 Link to this post

    Hi Guillaume,

    As far as we can tell this is an Internet Explorer problem and the encoding works properly when exporting from all other major browsers. According to How to encode the filename parameter of Content-Disposition header in HTTP? there is not much we can do to handle this problem nicely. I can offer an ugly kind of workaround that consists of creating an User Function and check if you export from the web viewer - change the document name accordingly e.g.:

    public static string HandleDocumentTitle(string text)
            {
                 HttpContext context = System.Web.HttpContext.Current;
                 if (context != null)
                 {
                     return "some_proper_name";
                 }
                 else return text;
            }

    and set the following expression for the DocumentName property = HandleDocumentTitle(Parameters.Parameter1.Value) where the report parameter Parameter1 contains the value of the reportName query string (you assign it to the parameter value instead to the DocumentName directly).

    Greetings,
    Steve
    the Telerik team

    HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

  3. DevCraft banner
  4. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 27 Apr Link to this post

    I'm experiencing a similar problem with the HTML 5 report viewer (not tested with the WebForms viewer) and IE (11).
    When having special characters in the DocumentName and exporting in IE, the document name/extension isn't present anymore at all (shows some weird string, see attached image).

    Would be thankful for any solutions!

  5. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 03 May Link to this post

    Hello Fridli,

    If it is a WbForms web application, please check if RadCompression is enabled and test excluding Telerik Reporting AXD handler or REST service (depending on the viewer) paths.

    For more details, please check HTML5 Viewer: Export operations fail in Chrome and Firefox with ERR_CONNECTION_RESET.


    In case the suggestion does not resolve the issue, please open a support ticket and send us a demo project that illustrates the settings reproducing the problem.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top