Date Field does not show string anymore

Stimulsoft Reports.NET discussion
Post Reply
Scotty2
Posts: 8
Joined: Wed Jan 31, 2018 2:17 pm

Date Field does not show string anymore

Post by Scotty2 »

In many reports I have for example a field formatted as „Date“. The expression for this field is for example
{Format("{0:dd.MM.yyyy}", DateStart)} - {Format("{0:dd.MM.yyyy}", DateEnd)}

In former versions of Stimulsoft Report it was interpreted as string if there was an expression other than a date.
In the version 2019.2.3.0 only the first date would be displayed in this field. The rest of this string will not be displayed.

There is an easy way to solve this problem by using format „General“ instead of “Date”.
But there are already many decentralized reports.

Is it possible to redo this behaviour, if there is more content then one date in the field?
If it is not possible, can you provide a method how I could locate such fields before rendering the report and change the field format from “Date” to “General” in the code of the report.

Please find attached an example report.

Thanks
Attachments
Example Date-Format does not show text.mrt
(7.63 KiB) Downloaded 148 times
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Date Field does not show string anymore

Post by Ivan »

Hello,
Is it possible to redo this behaviour, if there is more content then one date in the field?
Unfortunately no.
If it is not possible, can you provide a method how I could locate such fields before rendering the report and change the field format from “Date” to “General” in the code of the report.
You can use the following code, for example:

Code: Select all

report.Load("example date-format does not show text.mrt");

var comps = report.GetComponents();
foreach (StiComponent comp in comps)
{
    var txt = comp as StiText;
    if ((txt != null) && (txt.TextFormat is Stimulsoft.Report.Components.TextFormats.StiDateFormatService) && txt.Text.Value.Contains("{Format"))
    {
        txt.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiGeneralFormatService();
    }
}
Thank you.
Scotty2
Posts: 8
Joined: Wed Jan 31, 2018 2:17 pm

Re: Date Field does not show string anymore

Post by Scotty2 »

Thank you.
I will try the code provided.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Date Field does not show string anymore

Post by Lech Kulikowski »

Hello

Ok.
Please let us know if you need any additional help.

Thank you.
Post Reply