If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Exporting To Excel Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-05, 14:28
KlansMan KlansMan is offline
Registered User
 
Join Date: Apr 2004
Posts: 50
Exporting To Excel Problem

I have a page that exports a RS to excel. The page exports the recordset fine
but when you try do anything on the spreadsheet like use the subtotal function on it the totals come back as 0

Here's my code that exports the RS

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=OrangeMobCostCentreItemis ed_" & Request.QueryString("RQ") & ".xls"


%>
<!-- #INCLUDE file ="Connection/DBConnect.asp" -->
<%
Dim strRequest
strRequest = Request.QueryString("RQ")
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
SQLRequest = "My SQL Statement"
objRS.Open SQLRequest, objConn
If NOT objRS.EOF Then
%>
<TABLE BORDER=1>
<TR>
<%

' Loop through each Field, printing out the Field Names


For i = 0 to objRS.fields.count - 1
%>
<TD><% = objRS(i).name %></TD>
<% next %>
</TR>
<%

' Loop through rows, displaying each field

Do while not objRS.eof
%>
<TR>
<% For i = 0 to objRS.fields.count - 1
%>
<TD VALIGN=TOP>&nbsp;<%= objRS(i) %>
</TD>
<% Next %>

</TR>
<%
objRS.MoveNext
Loop


objRS.Close
objConn.close
ELSE
Response.Redirect "OrangeExcelReportRequestError.asp?E=CCI&R="& strRequest &""
End IF

%>

If any one has any ideas of why i can't do sums on my spreadsheet after export please let me know how i can solve this problem

Regards

KM
Reply With Quote
  #2 (permalink)  
Old 01-25-05, 07:58
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Quote:
Originally Posted by KlansMan
If any one has any ideas of why i can't do sums on my spreadsheet after export please let me know how i can solve this problem
Yes it seems like many times a field gets exported to Excel as text instead of as numbers and then in Excel a user can then format that column as numeric and then the Sum(...) should work.
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On