1.创建模板并放在所在包WEB下自命名的文件内
2.按钮:
<a class="nui-button" iconCls="icon-upload" οnclick="downloadTemplate()">下载模板</a>
以post方法提交表单
<div style="display:none;">
<form id="downloadTemp" method="post">
</form>
</div>
调用页面流
function downloadTemplate(){
var form = document.getElementById("downloadTemp");
form.action = "com.sgai.fssc.service.hec4cwgx.bgt.importDatas.flow?_eosFlowAction=export0";
form.submit();
}
3.创建页面流和要用到的逻辑构件
参数name为模板名称
逻辑构件:
导出模板后的,模板名称
4.所调用的java方法
@Bizlet("")
public class FileOperate {
public static final String CONTRIBUTION_COFRAME_UTILS = "org.gocom.components.coframe.dict";
public static final String MODULE_COFRAME = "coframe-config";
public static final String GROUP_EXCEL = "excel-config";
public static final String EXCEL_TEMPLATE_PATH = "excel_template_path";
@Bizlet("")
public String generatePath(String name){
String templateDir = ApplicationContext.getInstance().getWarRealPath()
+ ConfigurationUtil.getContributionConfig(CONTRIBUTION_COFRAME_UTILS, MODULE_COFRAME, GROUP_EXCEL, EXCEL_TEMPLATE_PATH);
String templateFile = templateDir + name;
return templateFile;
}
}