Crystal Report

Last Page is Blank in Crystal Report

When you check the checkbox New Page After, you will see an icon just right to it. This icon represents Formula Workshop. Click this icon and type NOT OnLastRecord.

Save and close the window, you are good to test this and praise me for the rest of your lives 🙂

Calculate duration of time in crystal reports

Create one formula field give name “tot_seconds”

local stringvar array completetime;
local numbervar totalseconds;

if({dtAttendance.Time}”N/A”) Then
(
completetime:=split({dtAttendance.Time},”:”);
totalseconds:= ((3600*cdbl(completetime[1])) + (60*cdbl(completetime[2]))+(cdbl(“00”)));
)

{dtAttendance.Time} time is a report field which is display time in report.

If Check In times agains chechout time not found then display ‘N/A’ and vice versa so that we haven’t calculate that time in total therefore i have to put if condition regarding this.

Now, create another formula field “totalTime”, paste below code in “edit formula” section.

WhilePrintingRecords;
NumberVar TotalSec := sum({@tot_seconds},{dtAttendance.Name});

NumberVar Hours := Truncate ( TotalSec / 3600);
NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60);

Totext ( Hours, ‘####’) + ‘:’+
Totext ( Minutes,’00’)

If you are putting “totalTime” field into grouo section it will display group wise total.

Dynamically Add Header in Crystal Report

string amount = amountTextBox.Text;
string titleString = ” Total Sanctions above “;

List investmentList = new List();
investmentList = new InvestmentManager().CollectAmountWiseInvestment(amount);

expirySanctionCrystalReport reportDocumentObject = new expirySanctionCrystalReport();

//Set Crystal Report Header
CrystalDecisions.CrystalReports.Engine.TextObject amountText = (CrystalDecisions.CrystalReports.Engine.TextObject)reportDocumentObject.ReportDefinition.ReportObjects[“dateText”];
amountText.Text = amount;

CrystalDecisions.CrystalReports.Engine.TextObject titleText = (CrystalDecisions.CrystalReports.Engine.TextObject)reportDocumentObject.ReportDefinition.ReportObjects[“TextTitle”];
titleText.Text = titleString;

reportDocumentObject.SetDataSource(investmentList);
amountWiseCrystalReportViewer.ReportSource = reportDocumentObject;
amountWiseCrystalReportViewer.RefreshReport();
amountWiseCrystalReportViewer.Visible = true;

Crystal report XML file as DataSource

Namespace:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;

Global variable:
CrystalDecisions.Web.Report rpt = new CrystalDecisions.Web.Report();
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt1;

Onbutton or Page Load or any event
rpt.FileName = Server.MapPath(“EventHistory.rpt”);
crdata.Report = rpt;

rpt1 = crdata.ReportDocument;

crp.ReportSource = rpt1;
crp.RefreshReport();

crp.DataBind();