Can anyone help?
I am creating a Temp file on my server and then allowing the user to download the CSV file to their local computer
I am struggling when the data contains a comma though as this moves the data to a new cell in excel ?
This is the code I am using
dim fso, txtNew, txtNewName
set fso=Server.CreateObject("Scripting.FileSystemObject")
txtNewName = fso.GetTempName
txtNewName = Left(txtNewName, len(txtNewName) -3) & "csv"
set txtNew=fso.CreateTextFile(Server.MapPath(".") & "\" & txtNewName, True, False)
Dim fld, row
txtNew.Write "Transaction Date, Transaction, Amount" & vbCrLf
Do While Not MySearch.EOF
row = ""
For Each fld in MySearch.Fields
row = row & fld.value & ","
Next
'replace last comma with vbCrLF
row = left(row, len(row) -1) & vbCrLf
txtNew.Write row
mySearch.MoveNext
Loop
txtNew.close
set txtNew=nothing
set fso=nothing
I am creating a Temp file on my server and then allowing the user to download the CSV file to their local computer
I am struggling when the data contains a comma though as this moves the data to a new cell in excel ?
This is the code I am using
dim fso, txtNew, txtNewName
set fso=Server.CreateObject("Scripting.FileSystemObject")
txtNewName = fso.GetTempName
txtNewName = Left(txtNewName, len(txtNewName) -3) & "csv"
set txtNew=fso.CreateTextFile(Server.MapPath(".") & "\" & txtNewName, True, False)
Dim fld, row
txtNew.Write "Transaction Date, Transaction, Amount" & vbCrLf
Do While Not MySearch.EOF
row = ""
For Each fld in MySearch.Fields
row = row & fld.value & ","
Next
'replace last comma with vbCrLF
row = left(row, len(row) -1) & vbCrLf
txtNew.Write row
mySearch.MoveNext
Loop
txtNew.close
set txtNew=nothing
set fso=nothing