Skip to content

Commit

Permalink
Update MainForm.cs
Browse files Browse the repository at this point in the history
添加:原始excel文件名为新生成文件的默认名称
  • Loading branch information
ThomasZJ committed Nov 19, 2018
1 parent 9ba3de9 commit 3ccd580
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public partial class MainForm : Form {
// 导出数据相关的按钮,方便整体Enable/Disable
private List<ToolStripButton> mExportButtonList;

// 打开的excel文件名,不包含后缀xlsx。。。
private String FileName;

/// <summary>
/// 构造函数,初始化控件初值;创建文本框
/// </summary>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3ccd580

Please sign in to comment.