frmMerageExcel.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace wispro.sp.winform
  11. {
  12. public partial class frmMerageExcel : Form
  13. {
  14. public frmMerageExcel()
  15. {
  16. InitializeComponent();
  17. }
  18. private void label1_Click(object sender, EventArgs e)
  19. {
  20. }
  21. private void btnSelectSavePath_Click(object sender, EventArgs e)
  22. {
  23. FolderBrowserDialog fbd = new FolderBrowserDialog();
  24. if(fbd.ShowDialog()== DialogResult.OK)
  25. {
  26. txtSaveFilePath.Text = System.IO.Path.Combine(fbd.SelectedPath, $"{DateTime.Now.ToString("yyyyMMdd")}-{DateTime.Now.Month -1}月份绩效计算案件清单.xlsx");
  27. }
  28. }
  29. private void btnAdd_Click(object sender, EventArgs e)
  30. {
  31. OpenFileDialog ofd = new OpenFileDialog()
  32. {
  33. Multiselect = true,
  34. Filter= "Excel文件|*.xls;*.xlsx|全部文件|*.*"
  35. };
  36. if(ofd.ShowDialog() == DialogResult.OK)
  37. {
  38. lstFiles.Items.AddRange(ofd.FileNames);
  39. }
  40. }
  41. public string SaveFilePath { get; set; }
  42. private void btnBeginMerage_Click(object sender, EventArgs e)
  43. {
  44. if (!string.IsNullOrEmpty(txtSaveFilePath.Text) && lstFiles.Items.Count > 0){
  45. string[] files = new string[lstFiles.Items.Count];
  46. for(int i = 0; i < lstFiles.Items.Count; i++)
  47. {
  48. files[i] = lstFiles.Items[i].ToString();
  49. }
  50. new wispro.sp.utility.ExcelHelper().MerageExcel(txtSaveFilePath.Text, files);
  51. SaveFilePath = txtSaveFilePath.Text;
  52. }
  53. this.DialogResult = DialogResult.OK;
  54. this.Close();
  55. }
  56. private void btnCancel_Click(object sender, EventArgs e)
  57. {
  58. this.DialogResult = DialogResult.Cancel;
  59. this.Close();
  60. }
  61. }
  62. }