Bài 7: Xuất kết quả report ra Excel, PDF

Bài 7: Xuất kết quả report ra Excel, PDF

Đọc mấy bài ở trên các bạn chắc đã nắm đc sơ sơ về crytal report rùi, giờ nói thêm về việc trích xuất ra các định dạng của Excel hoặc PDF

Các bạn cỏ thể sử dụng ExportOptions để tùy chỉnh các định dạng trích xuất. Quay lại bài đầu tiên, ta thêm 2 cái button nữa,sau khi đã tạo và hiển thị thành công report, ta có thể export ra pdf hoặc excel.

Đây là export ra 1 file excel (file test.xls sẽ dc tạo ở ổ C)

try
            {
                ExportOptions CrExportOptions;

                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions();
                CrDiskFileDestinationOptions.DiskFileName = "c:\\test.xls";
                CrExportOptions = cryRpt.ExportOptions;
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.Excel;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
                cryRpt.Export();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

Export ra pdf :

try
            {
                ExportOptions CrExportOptions;
                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
                CrDiskFileDestinationOptions.DiskFileName = "C:\\test.pdf";
                CrExportOptions = cryRpt.ExportOptions;
                {
                    CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                    CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                    CrExportOptions.FormatOptions = CrFormatTypeOptions;
                }
                cryRpt.Export();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
Bạn thấy bài viết này như thế nào?: 
Average: 10 (1 vote)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Bình luận (0)

 

Add Comment

Filtered HTML

  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Các thẻ HTML được chấp nhận: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Tự động ngắt dòng và đoạn văn.

Plain text

  • No HTML tags allowed.
  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Tự động ngắt dòng và đoạn văn.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Web service REST sẽ tuân thủ theo bốn nguyên tắc thiết kế cơ bản

Web service REST sẽ tuân thủ theo bốn nguyên tắc thiết kế cơ bản

REST (Representational State Transfer) đã được chọn sử dụng rộng rãi thay cho Web service dựa trên SOAP và WSDL

Yandex

Công cụ tìm kiếm Yandex số 1 ở Nga

Sau giờ làm việc buổi chiều, tôi  ngồi theo dõi mấy Crawler và Spider đang Index site, thấy có Yandex.ru

4 công cụ cần thiết cho Drupal development

4 công cụ cần thiết cho Drupal development

Developing Drupal sites can be quite a challenge and adventure. And this comes from those who call themselves Drupal developers.

Công ty diệt chuột T&C

 

Diet con trung