JS部分:
新建一个from在影藏的div下,然后提交这个from
function downLoadExcl(){
$("#submitForm").remove();
var supplierInfoIds = "111";
var path = "${ctxPath}/secKill/exportActivityUrl.do";
var html = '
}
java后台处理请求部分:
private static final String ATTACHMENT_FILENAME = "attachment; filename=\"";
private static final String STRING = "\"";
private static final String CONTENT_DISPOSITION = "Content-disposition";
private static final String APPLICATION_OCTET_STREAM = "APPLICATION/OCTET-STREAM";
private static final String ISO_8859_1 = "ISO-8859-1";
private static final String UTF_8 = "UTF-8";
private static final String USER_AGENT = "user-agent";
private static final String MSIE = "msie";
@RequestMapping("exportActivityUrl.do")
public void exportActivityUrl(HttpServletRequest request,
HttpServletResponse response) {
Map
// 生成excel
HSSFWorkbook workbook = secKillService
.querysupplierInfoByIdsAndExport(paramMap);
String excelname = "";
excelname = "秒杀活动链接.xls";
String newexcelname = "";
String isIE = request.getHeader(USER_AGENT);
try {
if (isIE.toLowerCase().indexOf(MSIE) < 0) {
// 解决中文excel文件名乱码问题,非IE
newexcelname = new String(excelname.getBytes(UTF_8),
ISO_8859_1);
} else {
// 解决中文excel文件名乱码问题,IE
newexcelname = URLEncoder.encode(excelname, UTF_8);
}
} catch (Exception e) {
logger.logException(e);
}
response.reset();
response.setContentType(APPLICATION_OCTET_STREAM);
response.setHeader(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + newexcelname + STRING); // 实现下载
try {
workbook.write(response.getOutputStream());// 实现输出
response.flushBuffer();
} catch (Exception e) {
logger.logException(e);
}
}
java后台,生成excl部分
/**
* 活动信息
*/
private static final String[] SIGNUP_KEY = { "商品编码", "商品名称", "秒杀价", "活动数量", "运费", "预热开始时间", "秒杀开始时间", "秒杀结束时间",
"秒杀活动链接" };
/**
* 活动信息
*/
private static final String[] SIGNUP_VALUE = { "productCode", "productName", "seckillPrice", "amount",
"mailingPrice", "preheadStartTime", "secKillStartTime", "secKillEndTime", "activityUrl" };
@Override
public HSSFWorkbook querysupplierInfoByIdsAndExport(
Map
// 声明一个工作薄
HSSFWorkbook workbook = new HSSFWorkbook();
// 查询导出信息
List