<!DOCTYPE html>
<%@ page contentType="application/msexcel;charset=utf-8" %>
<%@ page pageEncoding="UTF-8" language="java"%>
<%@ taglib uri="/tags/loushang-web" prefix="l"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%@ page import="java.net.URLDecoder"%>
<meta http-equiv="Content-Type" content="application/msexcel; charset=utf-8">
<html lang="en">
<head>
<title>核验列表</title>
</head>
<body>
<table align="left" border="2">
<thead>
<tr >
<th>序号</th>
<th>机构名称</th>
<th>组织机构代码</th>
<th>统一社会信用码</th>
<th>机构库查询结果</th>
<th>代码中心查询结果</th>
</tr>
</thead>
<tbody>
<c:forEach items="${datacontextMap.data}" var="item" varStatus="status">
<tr>
<td><c:out value="${status.index+1}"/></td>
<td><c:out value="${item.organization}"/></td>
<td><c:out value="${item.organization_code}"/></td>
<td><c:out value="${item.organization_uscc}"/></td>
<c:choose>
<c:when test="${item.local_result== '1' }">
<td>不存在</td>
</c:when>
<c:when test="${item.local_result== '2' }">
<td>存在</td>
</c:when>
<c:otherwise>
<td>全部</td>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${item.unitcenter_result== '1' }">
<td>不存在</td>
</c:when>
<c:when test="${item.unitcenter_result== '2' }">
<td>存在</td>
</c:when>
<c:otherwise>
<td>全部</td>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>
</tbody>
</table>
</body>
<% String ExcelName = "核验列表.xlsx";
ExcelName=new String(ExcelName.getBytes("GB2312"), "ISO_8859_1");//解决文件名为中文时文件错误的问题
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "inline; filename="
+ ExcelName);
%>
</html>打开当前页面就会导出excel,报错信息如下图如果导出xls格式是没有问题,header和ContentType这么写的话:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename="
+ ExcelName+".xls");
但是现在要求导出xlsx格式,求助大佬们,帮看看。
<%@ page contentType="application/msexcel;charset=utf-8" %>
<%@ page pageEncoding="UTF-8" language="java"%>
<%@ taglib uri="/tags/loushang-web" prefix="l"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%@ page import="java.net.URLDecoder"%>
<meta http-equiv="Content-Type" content="application/msexcel; charset=utf-8">
<html lang="en">
<head>
<title>核验列表</title>
</head>
<body>
<table align="left" border="2">
<thead>
<tr >
<th>序号</th>
<th>机构名称</th>
<th>组织机构代码</th>
<th>统一社会信用码</th>
<th>机构库查询结果</th>
<th>代码中心查询结果</th>
</tr>
</thead>
<tbody>
<c:forEach items="${datacontextMap.data}" var="item" varStatus="status">
<tr>
<td><c:out value="${status.index+1}"/></td>
<td><c:out value="${item.organization}"/></td>
<td><c:out value="${item.organization_code}"/></td>
<td><c:out value="${item.organization_uscc}"/></td>
<c:choose>
<c:when test="${item.local_result== '1' }">
<td>不存在</td>
</c:when>
<c:when test="${item.local_result== '2' }">
<td>存在</td>
</c:when>
<c:otherwise>
<td>全部</td>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${item.unitcenter_result== '1' }">
<td>不存在</td>
</c:when>
<c:when test="${item.unitcenter_result== '2' }">
<td>存在</td>
</c:when>
<c:otherwise>
<td>全部</td>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>
</tbody>
</table>
</body>
<% String ExcelName = "核验列表.xlsx";
ExcelName=new String(ExcelName.getBytes("GB2312"), "ISO_8859_1");//解决文件名为中文时文件错误的问题
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "inline; filename="
+ ExcelName);
%>
</html>打开当前页面就会导出excel,报错信息如下图如果导出xls格式是没有问题,header和ContentType这么写的话:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename="
+ ExcelName+".xls");
但是现在要求导出xlsx格式,求助大佬们,帮看看。
解决方案 »
- java代码怎么导入dmp文件到oracle数据库
- 怎样将从数据库中读取的数据显示在select的option中呢?
- hibernate问题 急
- hibernate 如何进行连接表(中间表)查询与更新
- tomcat 5.0的设置
- ASP问题,asp出现故障,只有在这里发了。 初学者的问题!~!~<
- html:select onchange 遇到的问题!
- 急!structs 问题,怎么找不到映射呀?
- JSP中,如何用代码实现跳转到另一个网页, 类似asp的response.redirect
- 关于数据流的操作问题。
- 新手ssm框架问题。 JDBC Connection will not be managed by Spring
- JSP中import问题
response.setContentType("application/octet-stream");