<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String fileName = "最简单的导出表格.xls";
fileName = new String(fileName.getBytes("GBK"),"ISO8859_1");
response.setHeader("Content-Disposition",
"attachment;filename="+fileName);
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Java Execl</title>
</head>
<body>
<TABLE id="Main" cellspacing="0" cellpadding="0" border="1" width="100%">
<TBODY>
<TR >
<TH nowrap="nowrap" style="TEXT-ALIGN: center" >代理商ID</TH>
<TH nowrap="nowrap" style="TEXT-ALIGN: center" >代理商名称</TH>
<TH nowrap="nowrap" style="TEXT-ALIGN: center" >联系手机</TH>
</TR>
<TR height="30">
<TD align="center" nowrap="nowrap"> July</TD>
<TD align="center" nowrap="nowrap"> 男</TD>
<TD align="center" nowrap="nowrap"> 羽毛球</TD>
</TR>
</TBODY>
</TABLE>
</body>
</html>
Java保存页面的内容为任意格式
最新推荐文章于 2021-11-12 09:24:23 发布
本文提供了一个使用Java实现的简单示例,用于导出包含特定数据的Excel表格。该示例展示了如何设置响应头以便正确下载文件,并定义了表格的基本结构。
1245

被折叠的 条评论
为什么被折叠?



