Exporting Numbers to Excel

Stimulsoft Reports.WPF discussion
Post Reply
RomanPer
Posts: 3
Joined: Fri Apr 27, 2018 5:49 pm

Exporting Numbers to Excel

Post by RomanPer »

I have a report that has a number of numeric fields. Each has been formatted as a number with different quantity of decimal places (some have 0, one has 5). All the fields are displayed properly in PDF output. However, when exporting the report to Excel, all the numeric fields are reset to 2 decimal points. Any ideas on an easy fix? Thanks in advance!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Exporting Numbers to Excel

Post by Edward »

Hi Roman,

Please try to use ExcelValue property, please check a sample in this topic:
viewtopic.php?&t=407

Thank you,
Edward
RomanPer
Posts: 3
Joined: Fri Apr 27, 2018 5:49 pm

Re: Exporting Numbers to Excel

Post by RomanPer »

Thanks Edward. I looked into it but I can't find much help on the Format function that I could use in that property.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Exporting Numbers to Excel

Post by Edward »

Hi Roman,

Could you please try to get the 'string' representation of that number without any formatting and to pass it to the ExcelValue, similar as per that sample, i.e. :

Code: Select all

public void Text1_GetExcelValue(object sender, Stimulsoft.Report.Events.StiGetExcelValueEventArgs e) 
{ 
  e.Value = "123456.78901"; 
} 
Thank you,
Edward
RomanPer
Posts: 3
Joined: Fri Apr 27, 2018 5:49 pm

Re: Exporting Numbers to Excel

Post by RomanPer »

Thank you Edward. I'll try it but I do need to format the numbers in specific formats. So, first, it's weird as to why Stimulsoft doesn't keep the formatting as defined in the properties. Second, do you know where I can find information on the syntax of the Format function?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Exporting Numbers to Excel

Post by Edward »

Hi Roman,

No problem!

Please check the following topic:
https://www.stimulsoft.com/en/documenta ... atting.htm

And for the format function if you require some extra functionality, please feel free to use the standard .Net formatting functions as follows:
https://docs.microsoft.com/en-us/dotnet ... at-strings

And some more techniques for you:
viewtopic.php?t=4354

Thank you,
Edward
Post Reply