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 quản lý VPS Virtual Private Server

Hướng dẫn quản lý VPS Virtual Private Server

Server mạnh với nhiều cấu hình cho phép khách hàng dễ dàng lựa chọn gói VPS phù hợp.

Các công ty trả lương hậu hĩnh nhất thung lũng Silicon

Các công ty trả lương hậu hĩnh nhất thung lũng Silicon

Trang web việc làm Glassdoor.com đưa ra danh sách các công ty công nghệ trả lương kĩ sư phần mềm cao nhất tại Thung lũng Silicon (Mỹ).

David Baker chia sẻ 11 suy nghĩ cần thiết cho Drupal team

There was an article by David Baker that caught my attention. David is a long-time consultant for the web agency marketplace who offers blunt

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

 

Diet con trung