The business of the company project requires users to print a file confirmation form when obtaining files. This function is implemented using Crystal Reports, but it is always slow for the first time when printing a list, according to rough calculations, it takes about 30 seconds to print data. I have read a lot on the Internet and many people have encountered the same problem. In some forums such as csdn, most people suspect that there are two reasons:
(1) Some people suspect that the check may be due to a large amount of data or SQL writing problems. Generally, I only have 1-10 pieces of data, which should not be a data problem.
(2) It is recommended that you change the control. If you do not want to use third-party things, you have also used the controls in Vs, but the export may be problematic, you can use the Operation Office to export directly to word printing, but you need to install office on the client
During debugging, it was found that the first printing time was slow because the setdatasource () method was stuck for a while, so I came up with a method to solve this problem and shared it with you. Instead of solving it, you just need to find a speculative method to hide it. I don't know much about the specific loading method of the crystal report, but according to debugging, I suspect that the first time the setdatasource () method is executed, the crystal report will load something, so it will be very slow, so when I started running the program, I wrote the following code)
1 # region cache file list
2
3 // to solve the problem of slow printing of the first CRYSTAL REPORT
4 datatable dt = new datatable ();
5 DT. Columns. Add ("Temp ");
6 // crystal report object
7 forms. Report. rptfilelist file = new forms. Report. rptfilelist ();
8 file. setdatasource (DT );
9
10 # list of endregion cache files
11 application. Run (new forms. frmmain ());
Obviously, I put this code in program. before loading the main form in CS, let the crystal report program load an empty datatable in advance, so that the crystal report can load everything to be loaded in advance, in this way, when the form is printed, it is almost a second .... It is not easy to write, and I hope it will help you with your questions.