1. 程式人生 > >jsp 文件導出到Excel

jsp 文件導出到Excel

print utf-8 res user -c info exc 學員 val

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>

jsp 文件導出到Excel