From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.Share.Windows/Report/GridCsv.cs |  125 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 125 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Share.Windows/Report/GridCsv.cs b/HotelPms.Share.Windows/Report/GridCsv.cs
new file mode 100644
index 0000000..20830f2
--- /dev/null
+++ b/HotelPms.Share.Windows/Report/GridCsv.cs
@@ -0,0 +1,125 @@
+using NPOI.HSSF.UserModel;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using HotelPms.Share.Util;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace HotelPms.Share.Windows.Report
+{
+    public class GridCsv : ReportBase, IDisposable, IReport
+    {
+        #region  ★★★★★ Declartions ★★★★★
+
+        private bool m_Disposed = false;
+
+        #endregion
+
+        #region  ★★★★★ Property ★★★★★
+
+        #endregion
+
+        #region  ★★★★★ Class Event ★★★★★
+
+        public GridCsv(DataTable data, GridStyle style)
+        {
+            m_Data = data;
+            m_Style = style;
+        }
+
+        ~GridCsv()
+        {
+            Dispose(false);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (!m_Disposed)   //一回だけ
+            {
+                if (disposing)
+                {
+                    //Managed Resources
+                }
+
+                //Unmanaged resources
+                m_Disposed = true;
+            }
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        #endregion
+
+        #region  ★★★★★ Control Event ★★★★★
+        #endregion
+
+        #region  ★★★★★ Private Function ★★★★★
+        #endregion
+
+        #region  ★★★★★ Public  Function ★★★★★
+
+        public void Output()
+        {
+            string path = System.IO.Path.GetTempFileName().Replace(".tmp", ".csv");
+            Output(path);
+            Process.Start(path);
+        }
+
+        public void Output(string file)
+        {
+            try
+            {
+                using (StreamWriter sw = new StreamWriter(file, false, Encoding.UTF8))
+                {
+                    StringBuilder colNames = new StringBuilder();
+                    int col = 0;
+                    foreach (ColumnStyle cs in m_Style.ColumnStyle)
+                    {
+                        if (col > 0) { colNames.Append(","); }
+                        colNames.Append("\"");
+                        colNames.Append(cs.Text);
+                        colNames.Append("\"");
+                        col++;
+                    }
+                    sw.WriteLine(colNames.ToString());
+
+                    //データ
+                    for (int i = 0; i < m_Data.Rows.Count; i++)
+                    {
+                        StringBuilder row = new StringBuilder();
+                        col = 0;
+                        foreach (ColumnStyle cs in m_Style.ColumnStyle)
+                        {
+                            string text = m_Data.Rows[i][cs.DataField].ToString();
+                            if (col > 0) { row.Append(","); }
+                            row.Append("\"");
+                            row.Append(text);
+                            row.Append("\"");
+                            col++;
+                        }
+                        sw.WriteLine(row.ToString());
+                    }
+
+                    sw.Close();
+                }
+            }
+            catch
+            {
+            }
+        }
+
+
+        #endregion
+
+    }
+}

--
Gitblit v1.10.0