private void wizard1_FinishButtonClick(object sender, CancelEventArgs e) { if (GetSelectedFields().Count == 0) { FISCA.Presentation.Controls.MsgBox.Show("必須至少選擇一項匯出欄位!", "欄位空白", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // 2017/8/22 穎驊依據高雄小組專案 [03-05][04+] EXCEL匯入格式可否修正為xlsx也可匯入? 更改為新版 Aspose.Cells_201402 寫法,支援.xlsx 匯出 saveFileDialog1.Filter = "Excel (*.xlsx)|*.xlsx|Excel (*.xls)|*.xls|所有檔案 (*.*)|*.*"; saveFileDialog1.FileName = "匯出學生基本資料"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { ExportStudentConnector ec = new ExportStudentConnector(); foreach (StudentRecord student in Student.Instance.SelectedList) { ec.AddCondition(student.ID); } ec.SetSelectedFields(GetSelectedFields()); ExportTable table = ec.Export(); ExportOutput output = new ExportOutput(); output.SetSource(table); try { output.Save(saveFileDialog1.FileName); PermRecLogProcess prlp = new PermRecLogProcess(); prlp.SaveLog("學生.匯出學生基本資料", "批次匯出", "匯出" + Student.Instance.SelectedKeys.Count + "筆學生資料."); } catch (Exception) { FISCA.Presentation.Controls.MsgBox.Show("檔案儲存失敗, 檔案目前可能已經開啟。", "儲存失敗", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (FISCA.Presentation.Controls.MsgBox.Show("檔案存檔完成,是否開啟該檔案", "是否開啟", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { System.Diagnostics.Process.Start(saveFileDialog1.FileName); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("開啟檔案發生失敗:" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.Close(); } }
private void btnSave_Click(object sender, EventArgs e) { //判斷勾選個數 if (GetSelectedFields().Count == 0) { FISCA.Presentation.Controls.MsgBox.Show("必須至少選擇一項匯出欄位!", "欄位空白", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // 2017/8/22 穎驊依據高雄小組專案 [03-05][04+] EXCEL匯入格式可否修正為xlsx也可匯入? 更改為新版 Aspose.Cells_201402 寫法,支援.xlsx 匯出 saveFileDialog1.Filter = "Excel (*.xlsx)|*.xlsx|Excel (*.xls)|*.xls|所有檔案 (*.*)|*.*"; saveFileDialog1.FileName = "匯出班級基本資料"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { //?? IExportConnector ec = new ExportClassConnector(); foreach (ClassRecord info in Class.Instance.SelectedList) { ec.AddCondition(info.ID); } ec.SetSelectedFields(GetSelectedFields()); ExportTable table = ec.Export(); ExportOutput output = new ExportOutput(); output.SetSource(table); output.Save(saveFileDialog1.FileName); if (FISCA.Presentation.Controls.MsgBox.Show("檔案存檔完成,是否開啟該檔案", "是否開啟", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { Process.Start(saveFileDialog1.FileName); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("開啟檔案發生失敗:" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.Close(); } }
private void btnSave_Click(object sender, EventArgs e) { if (GetSelectedFields().Count == 0) { FISCA.Presentation.Controls.MsgBox.Show("必須至少選擇一項匯出欄位!", "欄位空白", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } saveFileDialog1.Filter = "Excel (*.xls)|*.xls|所有檔案 (*.*)|*.*"; saveFileDialog1.FileName = "匯出課程基本資料"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { IExportConnector ec = new ExportCourseConnector(); foreach (CourseRecord course in Course.Instance.SelectedList) { ec.AddCondition(course.ID); } ec.SetSelectedFields(GetSelectedFields()); ExportTable table = ec.Export(); ExportOutput output = new ExportOutput(); output.SetSource(table); output.Save(saveFileDialog1.FileName); if (FISCA.Presentation.Controls.MsgBox.Show("檔案存檔完成,是否開啟該檔案", "是否開啟", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { Process.Start(saveFileDialog1.FileName); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("開啟檔案發生失敗:" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.Close(); } }