private void buttonX1_Click(object sender, EventArgs e) { ExportClass ex = new ExportClass(); if (!System.IO.File.Exists(Common.strAddfilesPath + "课程表")) { System.IO.Directory.CreateDirectory(Common.strAddfilesPath + "课程表"); } string filename = "课程表\\" + cbspcial.Text + "专业" + cbname.Text + "老师的" + cbclass.Text + "课程表"; filepath = Common.strAddfilesPath + filename + ".docx"; ex.MakeWordDoc(selectcommand, filename); MessageBox.Show("导出成功"); }
public ActionResult ExportCList(string cbspcial = "全部", string cbname = "全部", string cbclass = "全部") { ExportClass ex = new ExportClass(); string filename = cbspcial + "专业" + cbname + "老师的" + cbclass + "课程表" + ".docx"; string virtualPath = string.Format("~/App_Data/{0}/{1}/{2}", Session["AdminUser"], "课程表", filename); string fullFileName = this.Server.MapPath(virtualPath); string wordpath = Server.MapPath("~/Resources/classes.docx"); //创建文件夹,保存文件 string path = Path.GetDirectoryName(fullFileName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } ex.MakeWordDoc(selectExport(cbspcial, cbname, cbclass, lstclasses), fullFileName, wordpath); return(File(fullFileName, "application/zip-x-compressed", filename)); }