1. 程式人生 > >jsp頁面匯出excel表格

jsp頁面匯出excel表格

<%@ page contentType="application/vnd.ms-excel; charset=utf-8" %>
<%
response.setHeader("Content-Disposition", "attachment; filename=\"data_list" + (int)(Math.random() * 10000)+ ".xls\""); 
%>
<%
String tablestr = "";
tablestr = tablestr + "<table border=\"1\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\">";
tablestr = tablestr + "<tr>";
tablestr = tablestr + "<td><b>column</td>";
tablestr = tablestr + "<td><b>column</td>";
tablestr = tablestr + "<td><b>column</td>";
tablestr = tablestr + "<td><b>column</td>";
tablestr = tablestr + "<td><b>column</td>";
tablestr = tablestr + "<td><b>column</td>";
tablestr = tablestr + "<td><b>column</td>";
tablestr = tablestr + "</tr>";


tablestr = tablestr + "</tr></table>";


out.print(tablestr );
%>