jsp 文件导出到Excel

Java代码加:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=" + new String((userExpandDto.getRealname() + "学员个人档案").getBytes(),"ISO8859-1") + ".xls");
jsp页面加:
<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<!-- 显示网格线 -->
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>excel</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo/>
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
<!-- 显示网格线 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
posted @ 2017-10-27 19:27  音神  阅读(539)  评论(0编辑  收藏  举报