Reputation: 1243
I am struggling with exporting a Crystal Report to a Word document.
I'm creating the report with this code:
using (ReportDocument initRep = report.SetUpReportDocument(rep, loadId))
{
string filePath = @"C:\word2Pdf\";
string fileName = Guid.NewGuid().ToString() + "wordReport.doc";
var fileNameAndPath = filePath + fileName;
initRep.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, fileNameAndPath);
}
The problem is located here, on this line of code:
initRep.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, fileNameAndPath);
This is taking forever, with no any error.
My report has 4 subreports, which are linked to the main report with unique Id (loadId
).
I have been researching a lot here or even here and ...
When I am checking this using SQL Server Profiler, I find that the query is not pausing and it seems query running in screaming loop. I really need this to export, SOS.
Upvotes: 1
Views: 858
Reputation: 59
If those subreports are in a repeating section (details is the worst), then there'll be one query per subreport per section in the main report. That is, if your main report has 1000 records and the subreports are in the detail section, you'll have 4001 queries (1 for the main report, then 1000 for each subreport). To test, remove all the subreports, then add back one by one to see if one is worse than the others. It won't be so noticable in Crystal Reports designer as Crystal will only run the subreports when you navigate to the page. Try adding Total Page Count to the first page to see the horrible result.
Solution is typically to either do the work in a query or use SQL functions. Just depends upon your report needs.
Upvotes: 1