ExportExcelProgress.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Windows.Forms;
  5. namespace Dongke.IBOSS.PRD.Basics.BaseControls.ExportExcel
  6. {
  7. public partial class ExportExcelProgress : Form
  8. {
  9. public ExportExcel_EPPlus _eeep = null;
  10. private bool _done = false;
  11. public ExportExcelProgress()
  12. {
  13. InitializeComponent();
  14. }
  15. public Label StatusLabel
  16. {
  17. get
  18. {
  19. return this.label1;
  20. }
  21. //set
  22. //{
  23. // this.label1 = value;
  24. //}
  25. }
  26. public ProgressBar StatusBar
  27. {
  28. get
  29. {
  30. return this.progressBar1;
  31. }
  32. //set
  33. //{
  34. // this.label1 = value;
  35. //}
  36. }
  37. /// <summary>
  38. /// 取消
  39. /// </summary>
  40. /// <param name="sender"></param>
  41. /// <param name="e"></param>
  42. private void button1_Click(object sender, EventArgs e)
  43. {
  44. try
  45. {
  46. if (_done)
  47. {
  48. this.Close();
  49. }
  50. else
  51. {
  52. _eeep?.CancelExport();
  53. }
  54. }
  55. catch
  56. {
  57. }
  58. }
  59. /// <summary>
  60. /// 打开目录
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. private void button2_Click(object sender, EventArgs e)
  65. {
  66. try
  67. {
  68. if (_eeep != null)
  69. {
  70. string f = _eeep._exportParams.FilePath;
  71. string d = Path.GetDirectoryName(f);
  72. if (Directory.Exists(d))
  73. {
  74. Process.Start(d);
  75. return;
  76. }
  77. }
  78. }
  79. catch
  80. {
  81. }
  82. }
  83. /// <summary>
  84. /// 打开文件
  85. /// </summary>
  86. /// <param name="sender"></param>
  87. /// <param name="e"></param>
  88. private void button3_Click(object sender, EventArgs e)
  89. {
  90. try
  91. {
  92. if (_eeep != null)
  93. {
  94. string f = _eeep._exportParams.FilePath;
  95. if (File.Exists(f))
  96. {
  97. Process.Start(f);
  98. return;
  99. }
  100. }
  101. }
  102. catch
  103. {
  104. }
  105. }
  106. public void Done()
  107. {
  108. _done = true;
  109. button1.Enabled = true;
  110. button1.Text = "关闭";
  111. button2.Enabled = true;
  112. button3.Enabled = true;
  113. }
  114. private void ExportExcelProgress_FormClosing(object sender, FormClosingEventArgs e)
  115. {
  116. if (!_done)
  117. {
  118. e.Cancel = true;
  119. return;
  120. }
  121. _eeep?.Dispose();
  122. _eeep = null;
  123. }
  124. }
  125. }