To implement the table in the page to export into an Excel format, if you use JXL API, you will not avoid too much trouble, here I will introduce a simple export used in our project.
First, introduce the principle, Excel can open the html file, everyone should know? (I don't know this? Hehe
) The same truth, an HTML file having only Table elements can also be opened in Excel, so we can use the FORM submission in the page, submit it to a JSP or servlet, then by JSP or servlet Submitted Table content transit into a file stream, passed to the client in file download, thereby completing the exported Excel function.
The following is some of the query JSP page partial code:
Function SaveResult ()
{
Var idx = document.all.userid.selectedIndIndex;
IF (eVal (Document.ResultFrame.Restbl) == NULL)
{
Alert ("Please check it first!");
Return False;
}
Var file = "Daily War Query _" Document.All.datetime.Value
"_" Document.all.Userid.Options [IDX] .TEXT;
Document.all.name.value = file ". xls";
Document.all.txt.value = "