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

 
Hướng dẫn Multi-currency shops với Drupal Commerce

Hướng dẫn Multi-currency shops với Drupal Commerce

The new Drupal Commerce module brings shop building to a new level by fully leveraging the functionalities of Drupal 7. On the other hand the great flexibility of Drupal Commerce provides so many options sometimes it's unclear how to implement the right solution.

Sáng chế mới của Apple: MacBook lai máy tính bảng

Sáng chế mới của Apple: MacBook lai máy tính bảng

MacBook sẽ có khả năng xoay màn hình thành máy tính bảng, lại có thêm ăng-ten đem đến khả năng của chiếc điện thoại.

Facebook - iOS14.5 chính thức update toàn và điều gì mong đợi

Facebook - iOS14.5 chính thức update toàn và điều gì mong đợi

Vào ngày 26.04.2021 Apple chính thức ra mắt rộng rãi phiên bản iOS 14.5. kèm theo đó là những động thái rất ráo riết của các nền quảng cáo trong đó có Facebook

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

 

Diet con trung