Click here to Skip to main content
15,885,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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);
            
            //All works fine up till this and it gets stuck at the next statement

            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
Posted
Comments
The Doer 24-Jun-13 22:21pm    
what is the values of your TargetDirectory and memberID ??
Nayan Ambaliya 26-Jun-13 21:16pm    
The values are string: Say for example: TargetDirectory: C:\\Data\\ and MemberID: XMIM
RupenB 30-Jun-13 16:28pm    
Hello Nayan Ambaliya,

I need to export Crystal Report in Excel using Vb6 and using load report from specific path. I have search lot;s of, but not found any solution.

As per your post, I found that you have VB6 code for export to Excel. I request you, can you provide VB6 for me to write in my code for export data from Crystal report to VB6 using Report Document or any other thing ?

Thanks for you post and reply.

Thanks ,
Rupen
Mycroft Holmes 30-Jun-13 22:28pm    
First I would confirm that is is the actual export that is causing the timing blowout. Then I would get into Business Objects support forum and try and get an answer from them. This does not sound like a C# problem but a CR issue. The blowout does not surprise me as CR has had another 15 years of garbage development loaded into it and excel is somewhat more complex than in VB6 days so the export would be more convoluted.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900