From ad8f813f5eddd66740b4e09801e4ea02ddf70a4a Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期三, 19 二月 2025 15:58:22 +0800
Subject: [PATCH] 继续优化报表

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraForm1.cs |   70 ++++++++++++++++++++++++++++++-----
 1 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraForm1.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraForm1.cs
index e7d7612..2d520e1 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraForm1.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraForm1.cs
@@ -8,25 +8,75 @@
             this.Load += Form1_Load;
         }
 
+        private XtraReport1 _report1;
+
         public void SetBindingData(SimulationPrintViewModel viewModel)
         {
-            XtraReport1 report = new XtraReport1();
-            report.SetBingdingData(viewModel);
-            // 鐢熸垚鎶ヨ〃鏂囨。
-            report.CreateDocument();
+            _report1 = new XtraReport1();
+            _report1.SetBingdingData(viewModel);
 
+            // 鐢熸垚鎶ヨ〃鏂囨。
+            _report1.CreateDocument();
             // 灏嗘姤琛ㄦ枃妗e姞杞藉埌 DocumentViewer 涓�
-            documentViewer1.DocumentSource = report;
+            documentViewer1.DocumentSource = _report1;
         }
 
         private void Form1_Load(object sender, EventArgs e)
         {
-            XtraReport1 report = new XtraReport1();
-            // 鐢熸垚鎶ヨ〃鏂囨。
-            report.CreateDocument();
+            /*      XtraReport1 report = new XtraReport1();
+                  // 鐢熸垚鎶ヨ〃鏂囨。
+                  report.CreateDocument();
 
-            // 灏嗘姤琛ㄦ枃妗e姞杞藉埌 DocumentViewer 涓�
-            documentViewer1.DocumentSource = report;
+                  // 灏嗘姤琛ㄦ枃妗e姞杞藉埌 DocumentViewer 涓�
+                  documentViewer1.DocumentSource = report;*/
+        }
+
+        private void btnExportPDF_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            SaveFileDialog saveFileDialog = new SaveFileDialog();
+            // 璁剧疆鏂囦欢绛涢�夊櫒锛屽彧鍏佽閫夋嫨鐗瑰畾鏍煎紡鐨勬枃浠�
+            saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf|";
+            saveFileDialog.Title = "閫夋嫨淇濆瓨璺緞";
+
+            // 鏄剧ず瀵硅瘽妗嗗苟鑾峰彇鐢ㄦ埛閫夋嫨鐨勭粨鏋�
+            if (saveFileDialog.ShowDialog() == DialogResult.OK)
+            {
+                string filePath = saveFileDialog.FileName;
+
+                try
+                {
+                    _report1.ExportToPdf(filePath);
+                    TipFormHelper.ShowSucceed("瀵煎嚭鎴愬姛锛�");
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show($"瀵煎嚭鎶ヨ〃鏃跺彂鐢熼敊璇�: {ex.Message}", "瀵煎嚭澶辫触", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
+        }
+
+        private void btnExportWord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            SaveFileDialog saveFileDialog = new SaveFileDialog();
+            // 璁剧疆鏂囦欢绛涢�夊櫒锛屽彧鍏佽閫夋嫨鐗瑰畾鏍煎紡鐨勬枃浠�
+            saveFileDialog.Filter = "Word Files (*.docx)|*.docx";
+            saveFileDialog.Title = "閫夋嫨淇濆瓨璺緞";
+
+            // 鏄剧ず瀵硅瘽妗嗗苟鑾峰彇鐢ㄦ埛閫夋嫨鐨勭粨鏋�
+            if (saveFileDialog.ShowDialog() == DialogResult.OK)
+            {
+                string filePath = saveFileDialog.FileName;
+
+                try
+                {
+                    _report1.ExportToDocx(filePath);
+                    TipFormHelper.ShowSucceed("瀵煎嚭鎴愬姛锛�");
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show($"瀵煎嚭鎶ヨ〃鏃跺彂鐢熼敊璇�: {ex.Message}", "瀵煎嚭澶辫触", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
         }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3