By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Adding Currency symbol to excel report using ASP

P: 92
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ Language=VBScript %>
  3. <% Response.Buffer = True %>
  4. <!--#include file="connection.asp"-->
  5. <%
  6.             vSQL = Request.Form("SQLSelect")
  7.             SQLSelect = vSQL
  8.  
  9.             Set oRs_HotelRFP = Server.CreateObject("ADODB.RecordSet")
  10.  
  11.                 oRs.Open SQLSelect, Oconn
  12.  
  13.             If oRs.EOF = True then
  14.             Response.Write("No Records")
  15.             Else
  16. fileName = server.MapPath("Report.csv")
  17.  
  18.             set fso = server.CreateObject("Scripting.FileSystemObject")
  19.             set ts = fso.openTextFile(fileName, 2, true)
  20.  
  21.             Header = "GDS Code" & ","
  22.             Header = Header & "ID Number" & ","
  23.             Header = Header & "Report Name" & ","
  24.             Header = Header & "Address" & ","
  25.             Header = Header & "Address2" & ","
  26.             Header = Header & "City" & ","
  27.             Header = Header & "State" & ","
  28.             Header = Header & "Currency" & ","
  29.             Header = Header & "Country" & ","
  30.  ts.writeline(Ucase(left(Header, len(Header) - 1)))
  31. do while not oRs_HotelRFP.EOF
  32.                 'Ucase(  )  CAPITALIZATION    
  33.             strLine = UCase(replace(oRs.Fields("GDS_Code"), ",", " ")) & "," 
  34.             strLine = strLine & oRs.Fields("Rep_ID") & ","
  35.             strLine = strLine & UCase(replace(oRs.Fields("Report_Name"), ",", " ")) & ","
  36.             strLine = strLine & UCase(replace(oRs.Fields("Address"), ",", " ")) & ","
  37.             strLine = strLine & UCase(oRs.Fields("Address2")) & ","
  38.             strLine = strLine & UCase(replace(oRs.Fields("City"), ",", " ")) & ","
  39.             strLine = strLine & UCase(oRs.Fields("State_CD")) & ","
  40.             strLine = strLine & UCase(replace(oRs.Fields("Currency"), ",", " ")) & ","
  41. ts.writeline(Ucase(left(strLine, len(strLine) - 1)))
  42.                 oRs.movenext
  43.             strLine = ""    
  44.             loop
  45.             ts.close
  46.             set ts = nothing
  47.             set fso = nothing
  48.             Response.Write(SQLSelect)
  49.             Response.Redirect("Report.csv")
  50.  
  51.             End If        
  52. %>
  53. <html>
  54. <head>
  55. <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
  56. </head>
  57. <body>
  58.  
  59. <p>&nbsp;</p>
  60.  
  61. </body>
  62. </html>
  63.  
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
Oct 8 '10 #1
Share this Question
Share on Google+
1 Reply


danp129
Expert 100+
P: 321
Replace:
Expand|Select|Wrap|Line Numbers
  1. strLine = strLine & UCase(replace(oRs.Fields("Currency"), ",", " ")) & ","
With:
Expand|Select|Wrap|Line Numbers
  1. strLine = strLine & "$" & UCase(replace(oRs.Fields("Currency"), ",", " ")) & ","
Oct 13 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.