Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts

    creating excel from asp - losing numbers

    i create an excel from asp using the file system object

    my problem is there is a collumn with numbers such as

    00552222222

    all with 0's first. when i open the excel it removes the 0's in the collumn -- any suggestions to force it as a string in excel and not a number

  • #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    When you created the Excel database. Did you set those fields to be integer?

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts
    no

    i just do

    Code:
    Set fs = Server.CreateObject("Scripting.FileSystemObject")
         Set MyFile = fs.CreateTextFile(filename, True)
    
          Set rs = objconns.Execute(sql)
    
         strLine="<table><tr>" 'Initialize the variable for storing the filednames
    
         For each x in rs.fields
                 strLine= strLine & "<td>" & x.name & "</td>"
         Next
    	 	strline=strline&"</tr>"
           MyFile.writeline strLine
    
            Do while Not rs.EOF
         strLine="<tr>"
         for each x in rs.Fields
    	  	cell=x.value
    		strLine= strLine & "<td>" & cell & "</td>"
         next
    	 	strline=strline & "</tr>"
    		'response.write strline & vbcrlf
         MyFile.writeline strLine
    	
    	
         rs.MoveNext
      Loop
    	myfile.writeline "</table>"
        MyFile.Close
      Set MyFile=Nothing
      Set fs=Nothing

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    That's not an Excel file That's a HTML table.

    Put quotes round values for them to be parsed as strings.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •