Hi all experts,
I am currently working on a project of converting a VB6 utility to .NET platform using winforms and C#
The VB6 utility uses some third party tool to open the .rpt file, pass in new parameters to the report file and exports the fresh report to EXCEL programatically. There is no visual element involved. After it is done with all the reports, the utility closes itself. It is kind of a scheduled task on a windows server.
I do the same thing in .NET with winforms and C# using ReportDocument class of CrystalDecisions.CrystalReports.Engine namespace.
It works fine up till the load method and assigning parameters. The point where it gets stuck is the ExportToDisk() method where it exports to excel and saves the report to the file system.
Below is my code:
doc = new ReportDocument();
if (memberID == "xxx")
report3SelectionFormula = "{MemberID} in ['xxx', 'xxxx', 'xxxx', 'xxxx',] and ";
else
report3SelectionFormula = "{MemberID} = '" + memberID + "' and ";
report3SelectionFormula = "{class} in ['xxx', 'xxx'] and ";
report3SelectionFormula = report3SelectionFormula + "{@point} <> 'Yes' and ";
report3SelectionFormula = report3SelectionFormula + "{Type} = 'Debit' and ";
report3SelectionFormula = report3SelectionFormula + "{Date} >= Date(" + weekStarting.Year.ToString() + ", " + weekStarting.Month.ToString() + ", " + weekStarting.Day + ") and ";
report3SelectionFormula = report3SelectionFormula + "{Date} <= Date(" + weekEnding.Year.ToString() + ", " + weekEnding.Month.ToString() + ", " + weekEnding.Day + ") ";
doc.Load(SourceDirectory + WeeklyReport3);
doc.RecordSelectionFormula = report3SelectionFormula;
pf = null;
pf = new ParameterField();
pf.Name = "WeekEnding";
pf.ParameterValueType = ParameterValueKind.DateParameter;
pf.CurrentValues.Clear();
pdv.Value = weekEnding;
pf.CurrentValues.Add(pdv);
doc.DataDefinition.ParameterFields["WeekEnding"].ApplyCurrentValues(pf.CurrentValues);
doc.ExportToDisk(ExportFormatType.Excel, TargetDirectory + memberID + "\\ReportType03.xls");
In VB6 the time taken for the above code is like 1 second and .NET takes about 5 seconds to export this report. This has caused a significant increase in the total time as there are about 2000 such reports.
Please guide me in this direction on what can I do to improve.. The database query runs in like 0.5 seconds and returns on an average 7000 rows.
Awaiting for any reply.
Thanks.
Nay