Adding creation/printing date for report
Adding creation/printing date for report
Hello,
I've a task to place printing date with time on all kind of StimulSoft reports, and was wondering if it is already implemented in StimulSoft? If not, would much appreciate your guidance how to accomplish this task. We have a class SReport which inherits from StiReport class which is used to render all our reports. What I'm thinking at the moment is to override Load(string path) method to read 'mrt' file into MemoryStream and add TextBox with current date to the bottom of first page and load that Stream, but perhaps it is not a good idea.
Looking forward your suggestions.
Tynar.
I've a task to place printing date with time on all kind of StimulSoft reports, and was wondering if it is already implemented in StimulSoft? If not, would much appreciate your guidance how to accomplish this task. We have a class SReport which inherits from StiReport class which is used to render all our reports. What I'm thinking at the moment is to override Load(string path) method to read 'mrt' file into MemoryStream and add TextBox with current date to the bottom of first page and load that Stream, but perhaps it is not a good idea.
Looking forward your suggestions.
Tynar.
Adding creation/printing date for report
Hello,
As a way you can try to adding in report a additional text component with expression {DateTime.Now}
Thank you.
As a way you can try to adding in report a additional text component with expression {DateTime.Now}
Thank you.
Adding creation/printing date for report
What I've done so far:
But I cannot see desired result, could you please point me what I am missing.
Code: Select all
public override void Load(string path)
{
var rootDirectory = HttpContext.Current.Request.MapPath("~");
var reportFilePath = Path.Combine(rootDirectory, path);
base.Load(reportFilePath);
LoadDatabaseConf();
AddPrintDate();
}
public void AddPrintDate()
{
if (Pages.Count > 0)
{
StiPage firstPage = Pages[0];
StiFooterBand footerBand = new StiFooterBand(firstPage.ClientRectangle);
StiUnit unit = new StiHundredthsOfInchUnit();
double height = unit.ConvertFromHInches(30);
footerBand.Height = height;
footerBand.Name = "FooterBandReserved";
firstPage.Components.Add(footerBand);
//Create creation date.
StiText printDateText = new StiText();
printDateText.Height = unit.ConvertFromHInches(20);
printDateText.Width = unit.ConvertFromHInches(110);
printDateText.Text = DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss");
printDateText.Brush = new StiSolidBrush(Color.Black);
printDateText.Name = "FooterTextReserved";
printDateText.Font = new System.Drawing.Font("Times New Roman", 12f);
footerBand.Components.Add(printDateText);
}
}
Adding creation/printing date for report
Hello,
Please check the following code:
This code work correctly.
Thank you.
Please check the following code:
Code: Select all
if (Pages.Count > 0)
{
StiPage firstPage = Pages[0];
StiPageFooterBand footerBand = new StiPageFooterBand();
StiUnit unit = new StiHundredthsOfInchUnit();
double height = unit.ConvertFromHInches(30);
footerBand.Height = height;
footerBand.Name = "FooterBandReserved";
firstPage.Components.Add(footerBand);
//Create creation date.
StiText printDateText = new StiText();
printDateText.Height = unit.ConvertFromHInches(20);
printDateText.Width = unit.ConvertFromHInches(110);
printDateText.Text = DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss");
printDateText.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.None, System.Drawing.Color.FromArgb(255, 193, 152, 89), 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 4, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Black), false);
printDateText.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Transparent);
printDateText.Font = new System.Drawing.Font("Times New Roman", 12f);
printDateText.TextBrush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Black);
printDateText.Name = "FooterTextReserved";
footerBand.Components.Add(printDateText);
}
Thank you.
Adding creation/printing date for report
Thank you, it worked. I love this forum :biggrin:
Adding creation/printing date for report
Hello,
Great!
Great!