Unplanned
Last Updated: 13 Feb 2023 17:58 by Vinod
Vinod
Created on: 31 Jan 2023 20:14
Type: Bug Report
1
Telerik reports - Export to excel number formatting {0:N2} with trailing percent % symbol issue

When developing a Telerik report template with the intention of exporting to Excel, I observed the % sign was not displaying for positive numbers in the exported Excel file. The format we were using was {0:N2}%. The results displayed on the HTML report viewer and the Word export document was correct:

However in the excel file result, the cells were formatted without the % for positive numbers, and with the % for negative numbers.

Upon further inspection, I noticed the excel cell formatting was translated as:

This format would not generate the % symbol for a positive number as the trailing % is missing before the semi-colon.

We are fixing this by using the below Format specification directly in the Report Designer:

{0:#,##0.00"%";-#,##0.00"%"}

which is directly retained in the excel custom format:

While I understand that N, C etc. C# number formats are supported according to the design considerations and this bug is also technically resolved by using UseExtendedFormatting (setting this to false translates {0:N2} to #,##0.00"%"), this seems like an unexpected result of translating the format codes that does not match the standard behavior of {0:N2}%. Reporting this behavior for review.

 

 

 

 

 

2 comments
Vinod
Posted on: 13 Feb 2023 17:58
The {0:P2} formatting works well too. Thanks for the alternate approach Todor.
ADMIN
Todor
Posted on: 07 Feb 2023 12:13

Hello Vinod,

Thank you for describing the issue. I confirm it after testing locally.

We recognize this as a bug and we have updated your Telerik points as a token of gratitude for sharing the problem with us.

As an alternative workaround, you may divide the value by 100 and use the format {0:P2}. I have attached a demo report that demonstrates both the issue and the workaround.

Regards,
Todor
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Attached Files: