// private void WriteExcelByDataSet(DataSet dsExcel, string fileName) // { // //_writeSheetName = new List<string>(); // foreach (DataTable dtExcel in dsExcel.Tables) // { // if (dtExcel == null || dtExcel.TableName == null || dtExcel.TableName == "") continue; // ListHelper.RemoveEmptyRow(dtExcel); // //_dtExcel = dt; // WriteExcelByDataTable(dtExcel, fileName); // } // } private static void WriteExcel_Completed(object sender, BackgroundWorkerEventArgs e) { Process.Start(SaveFileDialog.FileName); // MessageBox.Show("导出完成"); // MessageBox.Show(e.BackGroundException == null // ? Path.GetFileName(_filePath) + "文件写入成功!" // : Path.GetFileName(_filePath) + "文件写入失败,请联系管理员!"); }
private readonly BackgroundWorkerEventArgs _eventArgs; //异常参数 public ProcessOperator() { _backgroundWorker = new BackgroundWorker(); _processForm = new FormProcess(); _eventArgs = new BackgroundWorkerEventArgs(); _backgroundWorker.DoWork += _backgroundWorker_DoWork; _backgroundWorker.RunWorkerCompleted += _backgroundWorker_RunWorkerCompleted; }
private void ReadExcel_Completed(object sender, BackgroundWorkerEventArgs e) { if (e.BackGroundException == null) { //if (readSheetName != null && readSheetName.Count > 0) //{ // //StringBuilder sb = new StringBuilder(); // //sb.Append("文件读取成功!\n\r已在" + filePath + "下\n\r读取了 " + readSheetName.Count.ToString() + " 张Sheet工作表\n\r分别是:\n\r"); // //int i = 0; // //foreach (String SheetName in readSheetName) // //{ // // i ++; // // sb.Append(SheetName + ","); // // if (i % 3 == 0) // // { // // sb.Append("\n\r"); // // } // //} // //String message = sb.ToString(); // //message = message.Substring(0, message.Length - 1); // //System.Windows.Forms.MessageBox.Show(message); //} //else //{ // MessageBox.Show("文件读取成功!\n\r已在" + filePath + "下\n\r读取了 0 张Sheet工作表"); //} if (_readSheetName == null || _readSheetName.Count == 0) { MessageBox.Show("文件读失败,未找到符合的系统要求的工作表!"); } } else { //MessageBox.Show("文件读取失败!\n\r已在" + filePath + "下\n\r读取了 0 张Sheet工作表\n\r请稍后在试!"); MessageBox.Show("文件读取失败,请联系管理员!"); } }