Page 1 of 1
Adding creation/printing date for report
Posted: Tue Jun 12, 2012 12:24 am
by tynar
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.
Adding creation/printing date for report
Posted: Tue Jun 12, 2012 3:03 am
by Alex K.
Hello,
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
Posted: Tue Jun 12, 2012 3:15 am
by tynar
What I've done so far:
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);
}
}
But I cannot see desired result, could you please point me what I am missing.
Adding creation/printing date for report
Posted: Tue Jun 12, 2012 8:20 am
by Alex K.
Hello,
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);
}
This code work correctly.
Thank you.
Adding creation/printing date for report
Posted: Wed Jun 13, 2012 2:29 am
by tynar
Thank you, it worked. I love this forum :biggrin:
Adding creation/printing date for report
Posted: Wed Jun 13, 2012 8:55 am
by Andrew
Hello,
Great!