public string CreateReport() { try { //ExpressProgross.ExpressProgressIndex(0); CreateCover(); ExpressProgross.SetProgress(10); word.InsertText("目录", 16, 1, Word.WdParagraphAlignment.wdAlignParagraphCenter, true); word.InsertNewPage(); ExpressProgross.SetProgress(20); ExpressProgross.RefreshCurrent(1); ChapterOne(); ExpressProgross.SetProgress(40); ExpressProgross.RefreshCurrent(2); ChapterTwo(); ExpressProgross.SetProgress(60); ExpressProgross.RefreshCurrent(3); ChapterThree(); ExpressProgross.SetProgress(70); ExpressProgross.RefreshCurrent(4); ChapterFour(); ExpressProgross.SetProgress(80); ExpressProgross.RefreshCurrent(5); ChapterFive(); word.CreateContents(); //ExpressProgross.ExpressProgressIndex(6); ExpressProgross.SetProgress(100); if (!Directory.Exists(m_path)) { Directory.CreateDirectory(m_path); } file_name = DateTime.Now.ToString("yyyy年M月d日H时m分") + "-演练结果报告"; word.SaveWordDocument(m_path, file_name); ExpressProgross.RefreshLast(5); return(file_name); } catch (Exception e) { return(""); } }
private void btn_Start_Click(object sender, EventArgs e) { if (btn_Start.Text.Equals("开始生成")) { btn_Start.Enabled = false; ExpressProgross.RefreshCurrent(0); ExpressProgross.SetProgress(0); BaseLogic baseLogic = new BaseLogic(m_sWordPath); m_sFileName = baseLogic.CreateReport(); } if (btn_Start.Text.Equals("开始生成") && m_sFileName != "") { MessageBox.Show("文档生成成功!"); btn_Start.Text = "查看文档"; btn_Start.Enabled = true; } else { if (!word.DisplayWordFile((object)(m_sWordPath + "/" + m_sFileName))) { MessageBox.Show("文档不存在或被占用"); } } }