您的位置:首页 > 编程语言 > C#

C# 导出word文档及批量导出word文档(3)

2015-06-27 17:04 751 查看
在初始化WordHelper时,要获取模板的相对路径。获取文档的相对路径多个地方要用到,比如批量导出时要先保存文件到指定路径下,再压缩打包下载,所以专门写了个关于获取文档的相对路径的类。

#region 将所有信息拼凑成一个word文档
public void getWordInfo(WordHelper wordhelper, string tempFile, string ntid, string stype, string mid, string sequence)
{
if (tempFile.Contains("实习生学习记录表导出模板"))
{
Dictionary<string, string> dicWhere = new Dictionary<string, string>();
dicWhere.Add("NTID", ntid);
wordhelper.GetBasicInfo(typeof(BLL.NewTraineeInfo), dicWhere);
PrejobTrainWord(wordhelper, ntid);
TrainListWord(wordhelper, ntid, stype, mid);
AwardListWord(wordhelper, ntid, stype, mid);
ArrangeListWord(wordhelper, ntid, stype);
ScoreListWord(wordhelper, ntid, stype, mid, sequence);
EvalWord(wordhelper, ntid, stype, mid);
}
}

#region 其他信息
//岗前培训
public void PrejobTrainWord(WordHelper wordhelper, string ntid)
{
Dictionary<string, string> dicWhere = new Dictionary<string, string>();
dicWhere.Add("NTID", ntid);
wordhelper.GetBasicInfo(typeof(BLL.PrejobTraining), dicWhere);
}

//轮科安排表
public void ArrangeListWord(WordHelper wordhelper, string ntid, string stype)
{
Dictionary<string, string> dicWhere = new Dictionary<string, string>();
dicWhere = new Dictionary<string, string>();
dicWhere.Add("NTID", ntid);
dicWhere.Add("StudentType", stype.ToString());
wordhelper.GetTableList(typeof(BLL.MajorCycle), dicWhere, "ArrangeList");
}


View Code

ArrangeList是之前在word模板里所设定的如下图,用for循环出列表,



getWordInfo里其它的方法类似这两个。

最后导出的word文档大致如下图所示:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: