From 3ccd580173bdb92683151572c4c4532a4a06c0e5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 19 Nov 2018 21:49:59 +0800 Subject: [PATCH] Update MainForm.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加:原始excel文件名为新生成文件的默认名称 --- GUI/MainForm.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index cc30184..78ac41a 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -29,6 +29,9 @@ public partial class MainForm : Form { // 导出数据相关的按钮,方便整体Enable/Disable private List mExportButtonList; + // 打开的excel文件名,不包含后缀xlsx。。。 + private String FileName; + /// /// 构造函数,初始化控件初值;创建文本框 /// @@ -114,6 +117,7 @@ private void jsonTextChanged(object sender, TextChangedEventArgs e) { private void loadExcelAsync(string path) { mCurrentXlsx = path; + FileName = System.IO.Path.GetFileNameWithoutExtension(path); //-- update ui this.btnReimport.Enabled = true; @@ -161,6 +165,7 @@ private void panelExcelDropBox_DragEnter(object sender, DragEventArgs e) { if (dropData != null && dropData.Length > 0) { string szPath = dropData[0]; string szExt = System.IO.Path.GetExtension(szPath); + FileName = System.IO.Path.GetFileNameWithoutExtension(szPath); szExt = szExt.ToLower(); if (szExt == ".xlsx") { e.Effect = DragDropEffects.All; @@ -234,6 +239,7 @@ private void saveToFile(int type, string filter) { SaveFileDialog dlg = new SaveFileDialog(); dlg.RestoreDirectory = true; dlg.Filter = filter; + dlg.FileName = FileName; if (dlg.ShowDialog() == DialogResult.OK) { lock (mDataMgr) { switch (type) {