java导出excel路径选择提示框或相对路径 10
publicvoidexecute()throwsException{StringtxtPath="e://test//";Filefile=newFile(txtPat...
public void execute() throws Exception {
String txtPath = "e://test//";
File file = new File(txtPath);
if (!file.exists()){
file.mkdirs();
}
String[] listHead = new String[] {"商户名称","分公司","地址","商户编号","终端号","是否在用"};
String[] listField = new String[] {"merchantName","company","address","merchantNumber","posNumber","isInUse"};
String sheetName = "商户资料";
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");// 可以方便地修改日期格式
String dt = dateFormat.format(now);
String errorPath = txtPath + dt + ".xls";
merchantList = merchantDao.findbyInput(sc);
exportService.doListToExcel(merchantList, listHead, listField, sheetName,
errorPath);
exportService.downloadFile(errorPath);
}
}
我这是写死的,求改成动态 展开
String txtPath = "e://test//";
File file = new File(txtPath);
if (!file.exists()){
file.mkdirs();
}
String[] listHead = new String[] {"商户名称","分公司","地址","商户编号","终端号","是否在用"};
String[] listField = new String[] {"merchantName","company","address","merchantNumber","posNumber","isInUse"};
String sheetName = "商户资料";
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");// 可以方便地修改日期格式
String dt = dateFormat.format(now);
String errorPath = txtPath + dt + ".xls";
merchantList = merchantDao.findbyInput(sc);
exportService.doListToExcel(merchantList, listHead, listField, sheetName,
errorPath);
exportService.downloadFile(errorPath);
}
}
我这是写死的,求改成动态 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |