private void BW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { SetForm(true); if (e.Error != null) { MessageBox.Show(e.Error.Message); return; } if (_DataRowCount == 0) { MessageBox.Show("沒有資料"); return; } Document doc = e.Result as Document; string reportName = _schoolYear + "學年度第" + _semester + "學期學期成績通知單"; MemoryStream memoryStream = new MemoryStream(); doc.Save(memoryStream, SaveFormat.Doc); ePaperCloud ePaperCloud = new ePaperCloud(); ePaperCloud.upload_ePaper(_schoolYear, _semester, reportName, "", memoryStream, ePaperCloud.ViewerType.Student, ePaperCloud.FormatType.Docx); }
//Word報表 public static void WordReport_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { object[] result = (object[])e.Result; string reportName = (string)result[0]; string path = (string)result[1]; Aspose.Words.Document doc = (Aspose.Words.Document)result[2]; string path2 = (string)result[3]; bool PrintStudetnList = (bool)result[4]; Aspose.Cells.Workbook wb = (Aspose.Cells.Workbook)result[5]; string Message = "" + result[6]; if (File.Exists(path2)) { int i = 1; while (true) { string newPath = Path.GetDirectoryName(path2) + "\\" + Path.GetFileNameWithoutExtension(path2) + (i++) + Path.GetExtension(path2); if (!File.Exists(newPath)) { path2 = newPath; break; } } } if (PrintStudetnList) { MemoryStream memoryStream = new MemoryStream(); doc.Save(memoryStream, Aspose.Words.SaveFormat.Doc); ePaperCloud ePaperCloud = new ePaperCloud(); ePaperCloud.upload_ePaper(Convert.ToInt32(School.DefaultSchoolYear), Convert.ToInt32(School.DefaultSemester) , reportName, "", memoryStream, ePaperCloud.ViewerType.Student, ePaperCloud.FormatType.Docx, Message); wb.Save(path2); FISCA.Presentation.MotherForm.SetStatusBarMessage(reportName + "產生完成"); System.Diagnostics.Process.Start(path2); } else { int schoolYear = Convert.ToInt32(School.DefaultSchoolYear); int semester = Convert.ToInt32(School.DefaultSemester); MemoryStream memoryStream = new MemoryStream(); doc.Save(memoryStream, Aspose.Words.SaveFormat.Doc); ePaperCloud ePaperCloud = new ePaperCloud(); ePaperCloud.upload_ePaper(schoolYear, semester, reportName, "", memoryStream, ePaperCloud.ViewerType.Student, ePaperCloud.FormatType.Docx, Message); FISCA.Presentation.MotherForm.SetStatusBarMessage(reportName + "產生完成"); } }