Add a dynamic date to file name
Posted: Wed Oct 20, 2021 6:25 am
Hi everyone,
I have a requirement where i need to dynamically add a date field to the filename at the time of export.
So the file name should look like "filename 202110". The dynamic part is the year + current month after filename.
The script language on the report is set to CSharp but I can switch that if required.
On the code page of the report i see the following,
I have seen one post here where the solution suggested was,
I tried to implement this but i am not getting the required result. Can you please share sample mrt files where you have implemented this requirement or direct me to an answer for this that was posted here previously. I am using Stimulsoft Designer Version 2021.3.1, WinFomrs , .NET 4.5
Thank you
I have a requirement where i need to dynamically add a date field to the filename at the time of export.
So the file name should look like "filename 202110". The dynamic part is the year + current month after filename.
The script language on the report is set to CSharp but I can switch that if required.
On the code page of the report i see the following,
Code: Select all
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using Stimulsoft.Controls;
using Stimulsoft.Base.Drawing;
using Stimulsoft.Report;
using Stimulsoft.Report.Dialogs;
using Stimulsoft.Report.Components;
namespace Reports
{
public class n10425859SL : Stimulsoft.Report.StiReport
{
public n10425859SL() {
this.InitializeComponent();
}
#region StiReport Designer generated code - do not modify
#endregion StiReport Designer generated code - do not modify
}
}
I have seen one post here where the solution suggested was,
Code: Select all
viewer.addEventListener(StiViewerEvent.START_EXPORT, onStaerExport);
...
private function onRetrieveColumns(event: StiViewerEvent): void
{
event.report.reportFile = event.report.reportName + StiDateTime.now.toString("YYYY-MM-dd");
}
Thank you