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.SourceFactory/ExcelCopy.cs |   66 +++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/HotelPms.SourceFactory/ExcelCopy.cs b/HotelPms.SourceFactory/ExcelCopy.cs
new file mode 100644
index 0000000..71782c3
--- /dev/null
+++ b/HotelPms.SourceFactory/ExcelCopy.cs
@@ -0,0 +1,66 @@
+using HotelPms.Share.Windows.Util;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace HotelPms.SourceFactory
+{
+    public partial class ExcelCopy : Form
+    {
+        public ExcelCopy()
+        {
+            InitializeComponent();
+        }
+
+        private void OpenExcel_Click(object sender, EventArgs e)
+        {
+            if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; }
+            txtExcelPath.Text = openFileDialog1.FileName;
+
+            cmbSheet.Items.Clear();
+            comboBox1.Items.Clear();
+            using (NPOIExcel excel = new NPOIExcel(txtExcelPath.Text))
+            {
+                for (int i = 0; i < excel.Workbook.NumberOfSheets; i++)
+                {
+                    cmbSheet.Items.Add(excel.Workbook.GetSheetAt(i).SheetName);
+                    comboBox1.Items.Add(excel.Workbook.GetSheetAt(i).SheetName);
+                }
+            }
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            List<string> srcData = new List<string>();  
+            using (NPOIExcel excel = new NPOIExcel(txtExcelPath.Text))
+            {
+                //元
+                excel.SetCurrentSheet(excel.Workbook.GetSheetIndex(cmbSheet.SelectedItem.ToString()));
+                Point begin = NPOIExcel.GetCellPoint(txtSrcBegin.Text);
+                Point end = NPOIExcel.GetCellPoint(txtSrcEnd.Text);
+
+                for(int r = begin.Y; r <= end.Y; r++)
+                {
+                    srcData.Add(excel.GetCellString($"{NPOIExcel.ToColName(begin.X + 1)}{r + 1}"));
+                }
+
+                //コピー
+                excel.SetCurrentSheet(excel.Workbook.GetSheetIndex(comboBox1.SelectedItem.ToString()));
+                begin = NPOIExcel.GetCellPoint(txtDstBegin.Text);
+                for (int i = 1; i <= srcData.Count; i++)
+                {
+                    excel.SetCell($"{NPOIExcel.ToColName(begin.X + 1)}{begin.Y + i}", srcData[i - 1]);
+                }
+
+                excel.Save();
+            }
+            MessageBox.Show("ok");
+        }
+    }
+}

--
Gitblit v1.10.0