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

Number Stored as Text - export to Excel

3 Answers 661 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rafał
Top achievements
Rank 1
Rafał asked on 21 Oct 2011, 12:57 PM

Hello Telerik Team,

I'm facing a problem with exporting a TextBox to excell file. Please take a look at the attached picture. I've created simple table with header and row. In that row I put numeric value of "1.222222" and I set up Format to {0:N2}. Now after exporting to excell file I got information "Number Stored as Text".

My question is: Is it possible to export this numeric value into excell file as a properly formatted number (1.22 stored as a number not as a text)?

Thanks in advance for your help.

3 Answers, 1 is accepted

Sort by
0
IvanDT
Telerik team
answered on 25 Oct 2011, 05:06 PM
Hello Rafał,

By default report items’ properties are strongly typed. If the Value starts with the equal (=) sign, it will be evaluated as an expression otherwise - as string value. For ex. if the value is 7 it is interpreted as the string "7"; To compare a numeric expression with the number 7, use the expression syntax which begins with the equal sign: =7.

Greetings, IvanDT
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Tomsz
Top achievements
Rank 1
answered on 25 Sep 2012, 11:35 AM
I got simply function that format my data for example
public static string KwotaZWaluta(decimal kwota) {             
    string r = "=" + kwota.ToString("0.00");             
    return r;         


In details section i bind field as = ...KwotaZWaluta(Fields.Naleznosc)

in report footer I had text box.

In code i set this.DataSource = <My Data as List<MyClass> > and also textbox1.Value = KwotaZWaluta(1.32);
As result of this operation in report viewer (before export to excel , in excel it's looks the same) i get report with value in details (=0.00 , =1.20 , =123.12), and correct format in text box 1.32 (without =).

Schould I had additonal configuration in details section ?

0
Steve
Telerik team
answered on 26 Sep 2012, 08:51 AM
Hi Tomsz,

The equal (=) sign is needed to indicate that the value would be evaluated as an expression. You already have equal sign in your TextBox expression just before the user function:

= KwotaZWaluta(Fields.Naleznosc)

You do not need to add "=" as part of the user function result. It should only return the desired formatted value.

Regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Rafał
Top achievements
Rank 1
Answers by
IvanDT
Telerik team
Tomsz
Top achievements
Rank 1
Steve
Telerik team
Share this question
or