Adding Currency symbol to excel report using ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandhseke
    New Member
    • Jun 2009
    • 92

    Adding Currency symbol to excel report using ASP

    Hi,
    I have requirement to pre-populate currency symbols in excel report generated using ASP. Please review the code below and help in fixing this.

    Code:
    <%@ Language=VBScript %>
    <% Response.Buffer = True %>
    <!--#include file="connection.asp"-->
    <%
    			vSQL = Request.Form("SQLSelect")
    			SQLSelect = vSQL
    	
    			Set oRs_HotelRFP = Server.CreateObject("ADODB.RecordSet")
    			
    				oRs.Open SQLSelect, Oconn
    				
    			If oRs.EOF = True then
    			Response.Write("No Records")
    			Else
    fileName = server.MapPath("Report.csv")
    			
    			set fso = server.CreateObject("Scripting.FileSystemObject")
    			set ts = fso.openTextFile(fileName, 2, true)
    			
                Header = "GDS Code" & ","
    			Header = Header & "ID Number" & ","
                Header = Header & "Report Name" & ","
    			Header = Header & "Address" & ","
    			Header = Header & "Address2" & ","
    			Header = Header & "City" & ","
    			Header = Header & "State" & ","
    			Header = Header & "Currency" & ","
    			Header = Header & "Country" & ","
     ts.writeline(Ucase(left(Header, len(Header) - 1)))
    do while not oRs_HotelRFP.EOF
    				'Ucase(  )  CAPITALIZATION	
                strLine = UCase(replace(oRs.Fields("GDS_Code"), ",", " ")) & "," 
    			strLine = strLine & oRs.Fields("Rep_ID") & ","
                strLine = strLine & UCase(replace(oRs.Fields("Report_Name"), ",", " ")) & ","
    			strLine = strLine & UCase(replace(oRs.Fields("Address"), ",", " ")) & ","
    			strLine = strLine & UCase(oRs.Fields("Address2")) & ","
    			strLine = strLine & UCase(replace(oRs.Fields("City"), ",", " ")) & ","
    			strLine = strLine & UCase(oRs.Fields("State_CD")) & ","
    			strLine = strLine & UCase(replace(oRs.Fields("Currency"), ",", " ")) & ","
    ts.writeline(Ucase(left(strLine, len(strLine) - 1)))
    				oRs.movenext
    			strLine = ""	
    			loop
    			ts.close
    			set ts = nothing
    			set fso = nothing
    			Response.Write(SQLSelect)
    			Response.Redirect("Report.csv")
    			
    			End If		
    %>
    <html>
    <head>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    </head>
    <body>
    
    <p>&nbsp;</p>
    
    </body>
    </html>
    The above code will bring back all the data based on the internal query condition. But i want currency value to be preceded with $ sign in the report.

    Any help would be greatly appreciated. Thanks.

    Regards,
    Chandhseke
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    Replace:
    Code:
    strLine = strLine & UCase(replace(oRs.Fields("Currency"), ",", " ")) & ","
    With:
    Code:
    strLine = strLine & "$" & UCase(replace(oRs.Fields("Currency"), ",", " ")) & ","

    Comment

    Working...