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

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

3 Answers 281 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Guillaume
Top achievements
Rank 1
Guillaume asked on 13 Feb 2013, 04:06 AM
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.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 15 Feb 2013, 05:10 PM
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!

0
Fridli Jacober
Top achievements
Rank 1
answered on 27 Apr 2016, 03:49 PM

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!

0
Stef
Telerik team
answered on 03 May 2016, 09:03 AM
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
Tags
General Discussions
Asked by
Guillaume
Top achievements
Rank 1
Answers by
Steve
Telerik team
Fridli Jacober
Top achievements
Rank 1
Stef
Telerik team
Share this question
or