469,326 Members | 1,242 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

how to genrate file with .xls format using asp

dear all,

i have to face many problem when i am genrating the excel file.
actually my need is that

i extract the data from data base through sql.
and store the data in excel sheet and this excel sheet is to be store where i want in my system.

plz give me the excet coding for this.

thanks and best regards
saurabh
Oct 26 '07 #1
2 1175
JamieHowarth0
533 Expert 512MB
Hi saurabh,

Your coding requirement is quite specific. Have you made any attempt at coding yourself? If you have, then show us your code and we will point you in the right direction.
If not, then also let us know and I will move this thread to the Jobs forum as it is a specific requirement for your needs that you will (more than likely) have to pay someone to develop for you.

Best regards,

medicineworker
Oct 27 '07 #2
hi medicineworker

right now i make a one control in which the control is genrate one file in CSV formats same as my requirment regarding excel file.
i am giving you the complete coading which i have to use for CSV file.

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <%
  3.  
  4.     showdt = "SMS_" & left(fromdate,2) & left(right(fromdate,7),2) & left(right(fromdate,4),4)
  5.  
  6. ' --------------------------
  7. ' CONNECTION
  8. ' --------------------------
  9.  
  10. pth = left(server.MapPath ("connnection.asp"),1)
  11. set con = server.createObject("ADODB.connection")
  12. con.open connectionstr1
  13. con.CommandTimeout = 900
  14. server.scripttimeout = 900
  15.  
  16. clcnt = 1
  17.  
  18.  
  19.  
  20. sql1 = "select Query(which retrive two column) "
  21.  
  22. set RS1 = server.CreateObject ("adodb.recordset") 
  23. rs1.CursorType = adOpenForwardOnly 
  24. rs1.Open sql1,con
  25. if not (rs1.bof and rs1.eof) then
  26.  
  27.  
  28.     Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
  29. '    Set MyTextFile=MyFileObject.CreateTextFile("C:\"&showdt&".txt",true)
  30.     Set MyTextFile=MyFileObject.CreateTextFile(pth&":\\inetpub\wwwroot\cgi-bin\RefcoExports\SMS_MarginCall\SMSfiles\"&showdt&".csv",true)
  31.     %>
  32. <HTML>
  33.  
  34. <head>
  35. </head>
  36.  
  37. <BODY >
  38.  
  39.     <%
  40.  
  41.     do while not rs1.EOF 
  42.  
  43.     sms = trim(rs1(0))
  44.  
  45.         variable = sms
  46.  
  47.     MyTextFile.WriteLine(variable) 
  48.  
  49.     rs1.MoveNext 
  50.         if rs1.EOF then
  51.             exit do
  52.         end if
  53.         Loop
  54.  
  55.     MyTextFile.Close
  56.     %>
  57.     <%
  58.     Response.Write "<font size=4 color=blue>File for Custody has been created with filename as <a href=http:SMSfiles/"& showdt &".csv>"& showdt &".csv</a></font>"
  59. else
  60.     con.close
  61.     Response.Write ("<CENTER><BR><BR><BR><P ><B><FONT color=red size=3>ALERT:</FONT><BR><FONT color=darkblue size=2>FILE WAS NOT CREATED AS NO RECORDS WERE FOUND.</FONT></B></CENTER></P>") 
  62. Response.End 
  63. end if 
  64. Response.End 
  65. %>
  66.  
  67. </body>
  68. </HTML>
  69.  



In this coding one csv file is genrated in one folder as well as it also produce one link in which we show the file immediatly and store the file where we want.
Oct 29 '07 #3

Post your reply

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

Similar topics

1 post views Thread by Job Lot | last post: by
1 post views Thread by Query Builder | last post: by
7 posts views Thread by John Dann | last post: by
9 posts views Thread by JimmyKoolPantz | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.