C
clemorama
Hi All,
I am having problems with serving an excel file to client web browsers.
I am creating a tab delimited .xls from a recordset. Below is the .asp
code.
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "sp_GetProviderPayments @StartDate='" & strStartDate &
"',@EndDate='" & strEndDate & "'"
objRS.Open strSQL,objConn
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
strPath = "C:\Web Projects\docs\"
strFileName = DatePart("m",strStartDate) & DatePart("d",strStartDate) &
DatePart("yyyy",strStartDate) & "_" & _
DatePart("m",strEndDate) & DatePart("d",strEndDate) &
DatePart("yyyy",strEndDate) & ".xls"
Set objLogFile = objFSO.CreateTextFile(strPath &
strFileName,true,false)
objLogFile.Write "Date" & vbTab
objLogFile.Write "Amount" & vbTab
objLogFile.Write "Provider" & vbTab
objLogFile.Write "Primary Name" & vbTab
objLogFile.Write "Child Name" & vbTab
objLogFile.Write "Case Manager" & vbTab
objLogFile.Write "Accounting CreatedBy" & vbTab
objLogFile.Write "Accounting Date Created"
objLogFile.WriteLine
While NOt objRS.EOF
objLogFile.Write CHR(34) & Trim(objRS("DDate")) & CHR(34) & vbTab
objLogFile.Write CHR(34) & Trim(objRS("Total")) & CHR(34) & vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("ProName")) & CHR(34)
& vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("PName")) & CHR(34) &
vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("CName")) & CHR(34) &
vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("uName")) & CHR(34) &
vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("CreatedBy")) &
CHR(34) & vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("CreatedDate")) &
CHR(34)
objLogFile.WriteLine
objRS.MoveNext
Wend
Set objLogFile = nothing
Set objFSO = nothing
Set objRS = nothing
Set objConn = nothing
The weird thing is that the file looks fine when I open it on the web
server but for some reason when I open the file from my web application
objRS("CName") and objRS("UName") are in the same column separated by a
".
Any suggestions?
I am having problems with serving an excel file to client web browsers.
I am creating a tab delimited .xls from a recordset. Below is the .asp
code.
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "sp_GetProviderPayments @StartDate='" & strStartDate &
"',@EndDate='" & strEndDate & "'"
objRS.Open strSQL,objConn
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
strPath = "C:\Web Projects\docs\"
strFileName = DatePart("m",strStartDate) & DatePart("d",strStartDate) &
DatePart("yyyy",strStartDate) & "_" & _
DatePart("m",strEndDate) & DatePart("d",strEndDate) &
DatePart("yyyy",strEndDate) & ".xls"
Set objLogFile = objFSO.CreateTextFile(strPath &
strFileName,true,false)
objLogFile.Write "Date" & vbTab
objLogFile.Write "Amount" & vbTab
objLogFile.Write "Provider" & vbTab
objLogFile.Write "Primary Name" & vbTab
objLogFile.Write "Child Name" & vbTab
objLogFile.Write "Case Manager" & vbTab
objLogFile.Write "Accounting CreatedBy" & vbTab
objLogFile.Write "Accounting Date Created"
objLogFile.WriteLine
While NOt objRS.EOF
objLogFile.Write CHR(34) & Trim(objRS("DDate")) & CHR(34) & vbTab
objLogFile.Write CHR(34) & Trim(objRS("Total")) & CHR(34) & vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("ProName")) & CHR(34)
& vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("PName")) & CHR(34) &
vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("CName")) & CHR(34) &
vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("uName")) & CHR(34) &
vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("CreatedBy")) &
CHR(34) & vbTab
objLogFile.Write CHR(34) & ReplaceForShow(objRS("CreatedDate")) &
CHR(34)
objLogFile.WriteLine
objRS.MoveNext
Wend
Set objLogFile = nothing
Set objFSO = nothing
Set objRS = nothing
Set objConn = nothing
The weird thing is that the file looks fine when I open it on the web
server but for some reason when I open the file from my web application
objRS("CName") and objRS("UName") are in the same column separated by a
".
Any suggestions?