JSP That Brings Up an Excel Spreadsheet

Here is a JSP that causes an Excel spreadsheet to be displayed in the browser. Of course, you can include Java code that dynamically fills in the rows of the spreadsheet, the data most likely coming from a database.

<%@ page import="java.sql.*, java.util.*"%>
   response.setHeader("Content-disposition", "attachment; filename=    Contacts.xls" );
 <table cellpadding="0" cellspacing="0" border="1">
   <tr style="font-weight: bold">
   <td>Expiration Date</td>
   <td>Lead Type</td>
   <td>Company Name </td>
   <td>First Name</td>
   <td>Last Name</td>
   <td>Email Address</td>
   <td>Age Group</td>
   <td>Own Home</td>
   <td>Marital Status</td>
   <td>Number of Employees</td>
   <td>Sales Volume</td>