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 CSV From Recordset

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-05-05, 19:37
KlansMan KlansMan is offline
Registered User
 
Join Date: Apr 2004
Posts: 50
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
Reply With Quote
  #2 (permalink)  
Old 02-13-05, 17:46
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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.
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