public String getContext(List<AgentBalanceInfo> agentBalanceInfoList) throws TemplateException, IOException {
String bufferString = null;
// 第一步:创建一个Configuration对象,直接new一个对象。构造方法的参数就是freemarker对于的版本号。
Configuration configuration = new Configuration(Configuration.getVersion());
// 第二步:设置模板文件所在的路径。
String fileUrl = this.getClass().getClassLoader().getResource("ftl").getPath();
configuration.setDirectoryForTemplateLoading(new File(fileUrl));
// 第三步:设置模板文件使用的字符集。一般就是utf-8.
configuration.setDefaultEncoding("utf-8");
// 第四步:加载一个模板,创建一个模板对象。
Template template = configuration.getTemplate("email.ftl");
// 第五步:创建一个模板使用的数据集,可以是pojo也可以是map。一般是Map。
Map<String,Object> dataModel = sendExcelMail(agentBalanceInfoList);;
//向数据集中添加数据
// dataModel.put("model", "hello word");
// 第六步:创建一个Writer对象,一般创建一FileWriter对象,指定生成的文件名。
Writer out = new StringWriter();
// 第七步:调用模板对象的process方法输出文件。
template.process(dataModel, out);
bufferString = out.toString();
// 第八步:关闭流。
out.close();
return bufferString;
}