Skip to content

Commit

Permalink
修改工作表保持功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Yang committed Apr 9, 2012
1 parent afa57b7 commit 5dbcdfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 12 additions & 1 deletion ExcelApplication/ExcelApplication/Form1.cs
Expand Up @@ -195,9 +195,20 @@ private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
}
}

string sheetName = "";
string sheetName = "W" + comboBox1.SelectedItem.ToString();
for (int i = 0; i < comboBox1.Items.Count; i++)
{
if (sheetName.GetHashCode() == comboBox1.GetItemText(comboBox1.Items[i]).GetHashCode())
{
sheetName = "W" + sheetName;
}
}

if (tmp.Save(sheetName, array))
{
comboBox1.DataSource = GetSheetNames(txtPath.Text);
MessageBox.Show("文件保存成功");
}
tmp.Close();
}
catch (Exception ex)
Expand Down
6 changes: 1 addition & 5 deletions ExcelApplication/ExcelApplication/Lib/Excel2007.cs
Expand Up @@ -84,11 +84,7 @@ public bool Save(string newSheetName, string[,] array)

if (ep == null) return false;
book = ep.Workbook;
if (newSheetName == "")
{
currentSheet = book.Worksheets.Add("WSheet");
}
else
if (newSheetName != null)
{
currentSheet = book.Worksheets.Add(newSheetName);
}
Expand Down

0 comments on commit 5dbcdfa

Please sign in to comment.