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

    Unanswered: Exporting To CSV From Recordset

    Hi there I have a page that exports my information fine to a csv file but i was wondering can you format the spreadsheet in any way ?

    As in

    When The value of a certain column changes put the next lot of information on a different sheet untill that value changes again and so on and so on

    Here is my code

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!-- #INCLUDE file ="Connection/DBConnect.asp" -->
    <%
    Dim strRequest
    strRequest = Request.QueryString("RQ")
    Dim RS, SQL

    SQL = "SELECT tbl_MobileItemised.MobileNumber, tbl_Employee.FullName, tbl_OrangeSummary.PayrollNo, tbl_OrangeSummary.CostCentre, tbl_MobileItemised.Field1, tbl_MobileItemised.Field2, tbl_MobileItemised.DateCall, tbl_MobileItemised.TimeCall, tbl_MobileItemised.NumberCalled, tbl_MobileItemised.PlacedCalled, tbl_MobileItemised.CallTime, tbl_MobileItemised.Field9, tbl_MobileItemised.CallCost, tbl_MobileItemised.Peak, tbl_MobileItemised.InvoiceDate, tbl_MobileItemised.Field13, tbl_MobileItemised.Field15 FROM (tbl_OrangeSummary INNER JOIN tbl_MobileItemised ON tbl_OrangeSummary.PhoneNumber = tbl_MobileItemised.MobileNumber) INNER JOIN tbl_Employee ON tbl_OrangeSummary.PayrollNo = tbl_Employee.PayrollNo WHERE tbl_OrangeSummary.CostCentre =""" & Request.QueryString("RQ") & """;"

    Set RS = ObjConn.Execute (SQL)

    if Not RS.EOF Then
    Dim F, Head
    For Each F In RS.Fields
    Head = Head & ", " & F.Name
    Next
    Head = Mid(Head,3) & vbCrLf
    Response.ContentType = "text/plain"
    Response.AddHeader "Content-Disposition", "attachment;filename=Orange_Mob_CostCentre_Itemise d_" & Request.QueryString("RQ") & ".csv"
    Response.Write Head
    Response.Write RS.GetString(,,", ",vbCrLf,"")
    ELSE
    Response.Redirect "OrangeExcelReportRequestError.asp?E=CCI&R="& strRequest &""
    End IF
    %>

    Hope some can till me if it is possable or not and if it is point me in the right direction

    Cheers for any help you give me

    KM

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    You can't do it with a csv as it is not a spreadsheet as such, just a text file format that Excel and read and understand and present in a spreadsheet format.

    It theory you could use the Excel objects to create a spreadsheet though. You would need to have these installed on your server though. And you would need to do a bit of work to get it all going.... but in theory it would work.

Posting Permissions

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