CreateTextFile Excel file formetting problem

Discussion in 'ASP General' started by clemorama@yahoo.com, Mar 24, 2006.

  1. Guest

    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?
    , Mar 24, 2006
    #1
    1. Advertising

  2. Scott Guest

    What does the ReplaceForShow() function do?

    What type of data is being placed in the column?
    Scott, Apr 12, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. spradl

    FileSystemObject.CreateTextFile Problem

    spradl, Aug 12, 2003, in forum: ASP General
    Replies:
    9
    Views:
    171
    Ray at
    Aug 14, 2003
  2. eddie wang

    filesys.createTextFile limit

    eddie wang, Dec 11, 2003, in forum: ASP General
    Replies:
    3
    Views:
    163
    Aaron Bertrand - MVP
    Dec 11, 2003
  3. Anchorman

    CreateTextFile hangs

    Anchorman, Jan 7, 2004, in forum: ASP General
    Replies:
    1
    Views:
    115
    Ray at
    Jan 7, 2004
  4. Séverine Donnay

    CreateTextFile deny on IIS

    Séverine Donnay, Jan 8, 2005, in forum: ASP General
    Replies:
    14
    Views:
    227
    Séverine Donnay
    Jan 9, 2005
  5. Andyza
    Replies:
    4
    Views:
    302
    Anthony Jones
    Feb 17, 2006
Loading...

Share This Page