Skip to content

Commit 76a3139

Browse files
github-actions[bot]KB BotIvetNikolovatodorarabadzhiev
authored
Added new kb article adjusting-currency-formatting-csv-export-reporting (#1938)
* Added new kb article adjusting-currency-formatting-csv-export-reporting * Update adjusting-currency-formatting-csv-export-reporting.md * Update adjusting-currency-formatting-csv-export-reporting.md * Update adjusting-currency-formatting-csv-export-reporting.md * Update adjusting-currency-formatting-csv-export-reporting.md --------- Co-authored-by: KB Bot <kb-bot@telerik.com> Co-authored-by: IvetNikolova <118352332+IvetNikolova@users.noreply.github.com> Co-authored-by: Todor Arabadzhiev <todor.arabadzhiev@progress.com>
1 parent 0c3dfd3 commit 76a3139

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Adjusting Currency Formatting for CSV Export
3+
description: Learn how to ensure numeric values are recognized correctly when exporting reports with currency formatting to CSV
4+
type: how-to
5+
page_title: Handling Currency Formatting for CSV Export in Reporting
6+
meta_title: Handling Currency Formatting for CSV Export in Reporting
7+
slug: adjusting-currency-formatting-csv-export-reporting
8+
tags: reporting, csv, export, currency formatting, textbox, format property, reportprocessor
9+
res_type: kb
10+
ticketid: 1703567
11+
---
12+
13+
## Environment
14+
15+
<table>
16+
<tbody>
17+
<tr>
18+
<td>Product</td>
19+
<td>Reporting</td>
20+
</tr>
21+
</tbody>
22+
</table>
23+
24+
## Description
25+
26+
When exporting reports to CSV with the ReportProcessor class in Telerik Reporting, currency values formatted using a [TextBox]({%slug telerikreporting/designing-reports/report-structure/textbox%})'s `Format` property (e.g., `"{0:C2}"`) include group separators and currency symbols. This formatting prevents Excel from recognizing the exported values as numbers. Contrary to expectations, the CSV rendering extension respects the `Format` property of report items, which is intentional behavior. Adjusting the `Culture` object does not resolve this issue due to changes in the report processing pipeline.
27+
28+
## Solution
29+
30+
To ensure numeric values are recognized correctly in CSV export, programmatically remove the `Format` property from the relevant TextBox items before exporting the report. The following examples demonstrate different approaches to resolving this issue:
31+
32+
Example 1:
33+
34+
Consider using data binding for the `Format` property:
35+
36+
`= RenderingFormat.Name = "CSV" ? Null : "{0:C2}"`
37+
38+
Example 2:
39+
40+
1. Locate the TextBox items in the report.
41+
1. Clear the `Format` property of the TextBox items programmatically before the export operation.
42+
43+
Here is an example implementation:
44+
45+
````CSharp
46+
private void GenerateReport(string format)
47+
{
48+
//...
49+
if (format == "CSV")
50+
{
51+
var textBox2 = report.Items.Find("textBox2", true).FirstOrDefault();
52+
(textBox2 as Telerik.Reporting.TextBox).Format = null;
53+
}
54+
//...
55+
}
56+
````
57+
58+
To apply this approach to multiple textbox items in similar scenarios, modify the code that locates the items as needed. For example:
59+
60+
````CSharp
61+
var textBoxItems = report.Items.Find(typeof(Telerik.Reporting.TextBox), true).ToList();
62+
````
63+
64+
This approach removes formatting applied to the TextBox items, ensuring the exported CSV contains raw numeric values.
65+
66+
## See Also
67+
68+
* [CSV Rendering Design Considerations]({%slug telerikreporting/designing-reports/rendering-and-paging/design-considerations-for-report-rendering/csv-rendering-design-considerations%})
69+
* [TextBox Report Item Overview]({%slug telerikreporting/designing-reports/report-structure/textbox%})
70+
* [Device Information Settings for the CSV rendering format]({%slug telerikreporting/using-reports-in-applications/export-and-configure/configure-the-export-formats/csv-device-information-settings%})

0 commit comments

Comments
 (0)