示例#1
0
 /**
  * Get Excel Report
  *
  * @param rule
  * @param sql
  * @param trxName
  * @param attachments
  * @return summary message to be added into mail content
  * @throws Exception
  */
 private String getExcelReport(
     MAlertRule rule, String sql, String trxName, Collection<File> attachments) throws Exception {
   ArrayList<ArrayList<Object>> data = getData(sql, trxName);
   if (data.size() <= 1) return null;
   // File
   File file = rule.createReportFile("xls");
   //
   ArrayExcelExporter exporter = new ArrayExcelExporter(getCtx(), data);
   exporter.export(file, null, false);
   attachments.add(file);
   String msg = rule.getName() + " (@SeeAttachment@ " + file.getName() + ")" + Env.NL;
   return Msg.parseTranslation(Env.getCtx(), msg);
 }