Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    50

    Unanswered: 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

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •