Link to home
Start Free TrialLog in
Avatar of sasha85
sasha85

asked on

syntax WriteLine on generating file

i'm need to create xls file:

Dim file_being_created,fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
file_being_created= Server.MapPath("text.xls")
Set act = fso.CreateTextFile(file_being_created, true)
 
 
act.WriteLine("<html><body>")
act.WriteLine("<table border=""1"">")
act.WriteLine("<tr>")
act.WriteLine("<th nowrap>State</th>")
act.WriteLine("<th nowrap>Abbreviaton</th>")
act.WriteLine("</tr>")
 
 
act.WriteLine("<tr>")
act.WriteLine("<td align=""right"">California</td>" )
act.WriteLine("<td align=""right"">CA</td>" )
act.WriteLine("</tr>")
 
act.WriteLine("<tr>")
act.WriteLine("<td align=""right"">Ohio</td>" )
act.WriteLine("<td align=""right"">OH</td>" )
act.WriteLine("</tr>")
 
 
act.WriteLine("</table></body></html>")
 
' close the object (excel)
act.close


but my real report code is written out of <% %>
means look like html...and when come a plaxe for asp i just open the <%
and closing it again...

is there a way to avoid rewriting all the code into the  
act.WriteLine("???")

can't i jus open is some how one time  
act.WriteLine("
///
and close it after all my code endes?
SOLUTION
Avatar of Emad Gawai
Emad Gawai
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
wow nice one but still there is repetation of htmlstr and file size also increased 792 bytes to 913 bytes
sory type i mean repetition  
Avatar of sasha85
sasha85

ASKER

still...it come's with code on the side...i understand that there is no other way then...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sasha85

ASKER

i am going to rewrite 142 rows then...it will be very ugly...my notepad wont like this...:)
can you paste your 142 rows here? May be i cna help you get it quickly and also will show you how to do that very quickly
It's unclear from the question why you are saving this text file.  It only really makes sense if it contains dynamic data.  What is the source of the data?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sasha85

ASKER

i got it all going with office...but i bump into a problem that i havn't thought about..
how can i insert asp codes and functions...if else for while...into act.WriteLine("
?
Avatar of sasha85

ASKER

how can i put asp code inside the act.WriteLine?
I would think you should still be able to put asp code inside of your writeline statement, as long as it's all encapsulated by the double quotes and that you watch for double quotes within the strings.  the script will treat it like a series of strings, which is what you would want.