I dont understand. Java code? JSP?
Also you should specify what exactly do you want to extract to .xls. One thing is to "convert" the webpage to PDF, for excel you need to specify what and where to save.
Anyway, because I'm not sure you're using JSP (or web development language at all..) you could accomplish it using Javascript
<script language=javascript>
function exportToExcel()
{
var oExcel = new ActiveXObject("Excel.Application");
var oBook = oExcel.Workbooks.Add;
var oSheet = oBook.Worksheets(1);
for (var y=0;y<detailsTable.rows.length;y++)
// detailsTable is the table where the content to be exported is
{
for (var x=0;x<detailsTable.rows(y).cells.length;x++)
{
oSheet.Cells(y+1,x+1) =
detailsTable.rows(y).cells(x).innerText;
}
}
oExcel.Visible = true;
oExcel.UserControl = true;
}
</script>
<button onclick="exportToExcel();">Export to Excel File</button>
<table name="detailsTable">
<tr>
<td> hello
</td>
</tr>
</table>