1 Replies - 12978 Views - Last Post: 23 September 2010 - 11:53 PM Rate Topic: -----

#1 Snehal N   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-November 09

How to generate excel file using asp.

Posted 23 September 2010 - 04:14 AM

How to generate excel file using asp button event?

<!--
<%@ Language=VBScript %>
<% 
dim Cn,Rs
set Cn=server.createobject("ADODB.connection")
set Rs=server.createobject("ADODB.recordset")
Cn.open "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("Sample.mdb")
Rs.open "select * from Emp",Cn,1,3
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls" 
if Rs.eof <> true then
response.write "<table border=1>"
while not Rs.eof
response.write "<tr><td>" & Rs.fields("ID") & "</td><td>" & 

Rs.fields("Name") & "</td><td>" & Rs.fields("Address") & "</td><td>" & Rs.fields("Descr") & 

"</td></tr>"
Rs.movenext
wend
response.write "</table>"
end if
set rs=nothing
Cn.close
%>
-->




this code didnt work,i want to generate excel file on button event.
<input type="button" value="Generate Excel sheet" onclick=" ">

how to call above function on button event.

Is This A Good Question/Topic? 0
  • +

Replies To: How to generate excel file using asp.

#2 Snehal N   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-November 09

Re: How to generate excel file using asp.

Posted 23 September 2010 - 11:53 PM

[code]
<!-- #INCLUDE FILE="connectionEnt1.asp"-->

<%Response.Buffer = true%>
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=file01.xls"
%>

<%
dim BranchName
dim FinYear
FinYear =Request.QueryString("FinYear")
BranchName= Request.QueryString("BranchName")

%>
<html>
<head>
<title>File01</title>
</head>
<body>
<center>
<form name=frmcaseupdate method=post>
<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr bgcolor=#FFCE9D align="Center">
<td colspan="2">Branchwise New Case Report</td>
</tr>
</b>
</table>
<table> <tr><td ><b>Report as on <%=date()%></b> </td> </tr> </table>

<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr ALIGN="center">
<td width=5%><font SIZE="2" face="Verdana">
<b>Case No</b></font>
</td>
<td width=7%><font SIZE="2" face="Verdana">
<b>Start Date</b></font>
</td>
<td width="20%"><font SIZE="2" face="Verdana">
<b>Case Description</b></font>
</td>
<td width="20%"><font SIZE="2" face="Verdana">
<b>Current Status</b></font>
</td>
<td width="7%"><font SIZE="2" face="Verdana">
<b>Case Category</b></font>
</td>
<td width="5%"><font SIZE="2" face="Verdana">
<b>Amount</b></font>
</td>
</tr>

<%set list=con.execute("Select * from courtcase_new where FinYear='"& FinYear &"' and BranchName='"& BranchName &"' and casedrop is null and decreed is null")%>
<%while not list.Eof%>

<tr align="center">
<td width=5%><font SIZE="2" face="Verdana">
<b><%=list("caseno")%></b></font>
</td>
<td width=7%><font SIZE="2" face="Verdana">
<b><%=list("startdate")%></b></font>
</td>
<td width="20%"><font SIZE="2" face="Verdana">
<b><%=list("particulars")%></b></font>
</td>
<td width="20%"><font SIZE="2" face="Verdana">
<b><%=list("currentstatus")%></b></font>
</td>
<td width="7%"><font SIZE="2" face="Verdana">
<b><%=list("Casecategory")%></b></font>
</td>
<td width="5%"><font SIZE="2" face="Verdana">
<b><%=list("amount")%></b></font>
</td>
</tr>
<%list.MoveNext%>
<%Wend%>
</table>
</center>
<br>
<br>
<table>
<tr>
<%set sum =con.execute("Select sum(amount)as Total from courtcase_new where BranchName='"& BranchName &"' ")%>
<td align="left"> <b>Contingent Liability as on <%=date()%> : <%=sum("Total")%> </b></td>
</tr>
<tr>
<td> <b>Note:</b><font color="Red">
The Contingent Liability of Rs. 9 Crores in respect of the Special Civil Suit in Kolkata High Court <br>
was decided by the Board to be deleted from the accounts during the approval to the Financial Results <br>
for the period ending March 31, 2009.
</td>
</tr>

</table>
</body>
</html>
[\code]

Above code is succully generate the excel sheet, but now problem is
it can't display records which lies in list.
so pls help me
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1