Export database content to excel sheet

by Vinoth 2009-04-15 14:52:17


< %@page contentType="application/vnd.ms-excel" language="java"%>
< %@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
< %@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
< sql:setDataSource var="dataSource" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dbn" user="root" password="***" />
< sql:query var="users" dataSource="${dataSource}">
select* from tb1;
< /sql:query>
<%
response.setHeader("Content-Disposition","attachment;filename=Backup.XLS");
%>
< table>< tr >
< td > < c:out value="${row.name}" / > < /td >
< td > < c:out value="${row.id}" / > < /td >
< td > < c:out value="${row.uid}" / > < /td >
< td > < c:out value="${row.time}" / > < /td >
< /tr > < /c:forEach >

< /table >

Tagged in:

2268
like
0
dislike
0
mail
flag

You must LOGIN to add comments