Replace the <% @ page contenttype = "text / html; charset = GBK" @ Page Contenttype = "Java"%>
<% @ Page ContentType = "Application / VND.ms-Excel; Charset = GBK" Language = "Java"%> // Excel
or
<% @ Page ContentType = "Application / VND.MS-Word; Charset = GBK" Language = "Java"%> // Word
Add a line in front of the page start output data
<%
Response.setHeader ("Content-Disposition", "Attachment; FileName = Result.xls"); // Excel
%>
or
<%
Response.setHeader ("Content-Disposition", "Attachment; FileName = Result.doc"); // Word
%>
Handling of other parts of the page:
Remove the imported CSS file (can join