Click to See Complete Forum and Search --> : Save table data displayed on the web page in excel format!!


shanuragu
12-01-2003, 03:54 AM
Hi

I have displayed Invoice details on a web page in a table format as shown below. The same data should be stored in Excel file format on click of some button say "Save". Is it possible???

How can I achive this???

<table id="tab1" width="99%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="24%" align="left"><font class="shnText"><b>Customer Name</b></font></td>
<td width="18%" align="left"><font class="shnText"><b>Invoice No</b></font></td>
<td width="14%" align="center"><font class="shnText"><b>Invoice Date</b></font></td>
<td width="14%" align="center"><font class="shnText"><b>Due Date</b></font></td>
<td width="12%" align="center"><font class="shnText"><b>Invoice Amount</b></font></td>
<td width="18%" align="center"><font class="shnText"><b>Total Amount</b></font></td>
</tr>
<%
if ((strFromDate = "") And (strToDate = "")) Then
If rsInvoices.RecordCount > 0 Then
Dim strOldMonth

strOldMonth = Month(rsInvoices("invoice_dt"))

While Not rsInvoices.Eof
lInvoiceAmt = Round(CDbl(rsInvoices("invoice_amt")) + CDbl(rsInvoices("tax_amt")))
lTotalOutstanding = lTotalOutstanding + lInvoiceAmt

If CInt(strOldMonth) <> CInt(Month(rsInvoices("invoice_dt"))) Then
strOldMonth = Month(rsInvoices("invoice_dt"))
%>
<tr>
<td width="85%" align="right" colspan="5"><font class="shnText"><b>MONTHLY TOTAL :</b></font></td>
<td width="15%" align="right"><font class="stepTextSmall"><b>Rs <%=objUtils.FormatString(CStr lMonthTotal), "#,##,##0.00")%></b></font></td>
</tr>
<%
lMonthTotal = 0
End if
lMonthTotal = lMonthTotal + lInvoiceAmt
%>
<tr>
<td width="24%" align="left"><font class="shnTextSmall"><%=rsInvoices("user_nm")%></font></td>
<td width="18%" align="left"><font class="shnTextSmall"><%=Session("bill_prefix")%><%=objUtils.FormatString(CStr(rsInvoices("invoice_no")), "##0000")%></font></td>
<td width="14%" align="center"><font class="shnTextSmall"><%=objUtils.FormatString(CStr(rsInvoices("invoice_dt")), "mmm dd yyyy")%></font></td>
<td width="14%" align="center"><font class="shnTextSmall"><%=objUtils.FormatString(CStr(rsInvoices("due_dt")), "mmm dd yyyy")%></font></td>
<td width="12%" align="center"><font class="shnTextSmall">Rs <%=objUtils.FormatString(CStr(rsInvoices("invoice_amt")), "#,##0.00")%></font></td>
<td width="18%" acign="center"><font class="shnTextSmall">Rs <%=objUtils.FormatString(CStr(lInvoiceAmt), "#,##,##0.00")%></font></td>
</tr>
<%
rsInvoices.MoveNext
Wend
%>
<tr>
<td width="85%" align="right" colspan="5"><font class="shnText"><b>MONTHLY TOTAL :</b></font></td>
<td width="15%" align="right"><font class="stepTextSmall"><b>Rs <%=objUtils.FormatString(CStr(lMonthTotal), "#,##,##0.00")%></b></font></td>
</tr>
<tr>
<td width="85%" align="right" colspan="5"><font class="shnText"><b>GRAND TOTAL :</b></font></td>
<td width="15%" align="right"><font class="stepTextSmall"><b>Rs <%=objUtils.FormatString(CStr(lTotalOutstanding), "#,##,##0.00")%></b></font></td>
</tr>

Shara

lillu
12-02-2003, 03:48 AM
Well, here's a technique that creates a table in Excel format dynamically in the browser.
Making it executing dynamically by a clicking of a button should be no problem either.

http://www.aspalliance.com/articleViewer.aspx?aId=1&pId=

shanuragu
12-05-2003, 11:39 PM
Thanks Lillu, ur reference helped me to get through the problem, it is very simple. I replce my 50 line code for dowmloading just with two line.

Thanks once again for ur help:D