ASP Free Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherASP Free Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 25th, 2004, 10:12 AM
vlopes vlopes is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 vlopes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Export data from TextFile to Ms-Excel

Can anyone help me on this: I have a TextFile in the server side.

And a I need to open the data from it but in client side, in a worksheet of

ms-excel.

Can somenone explain to me how to do this.
An example of the structure of the text file goes in attach
Thanks in advance
Attached Files
File Type: txt testread.txt (134 Bytes, 639 views)

Reply With Quote
  #2  
Old February 25th, 2004, 10:38 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
To Open a txt file in excell

Launch excel

File Open

File type: *.txt
Select you txt file
Open and answer the wizard questions

S_

Reply With Quote
  #3  
Old February 25th, 2004, 10:44 AM
vlopes vlopes is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 vlopes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The real problem

Quote:
Originally Posted by sbaxter
To Open a txt file in excell

Launch excel

File Open

File type: *.txt
Select you txt file
Open and answer the wizard questions

S_

yes i'm sorry that i have explain the problem badly.

I need to do that but using ASP

Thanks

Reply With Quote
  #4  
Old February 25th, 2004, 10:49 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
Post your full question in the ASP part of the forum. I don't know enough about ASP to help you, but there are other in that part that should be able to assist you.

S-

Reply With Quote
  #5  
Old February 25th, 2004, 11:41 AM
frankcow's Avatar
frankcow frankcow is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: http://www.justin-cook.com
Posts: 133 frankcow User rank is Private First Class (20 - 50 Reputation Level)frankcow User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 34 m 16 sec
Reputation Power: 5
set the response type to excel, and open the text file with the FileSystemObject
Response.ContentType = "application/vnd.ms-excel"

Reply With Quote
  #6  
Old February 25th, 2004, 12:30 PM
vlopes vlopes is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 vlopes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by frankcow
set the response type to excel, and open the text file with the FileSystemObject
Response.ContentType = "application/vnd.ms-excel"

Hello my Friend

I Have done that already and it still doesn't work...

Reply With Quote
  #7  
Old February 25th, 2004, 04:18 PM
frankcow's Avatar
frankcow frankcow is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: http://www.justin-cook.com
Posts: 133 frankcow User rank is Private First Class (20 - 50 Reputation Level)frankcow User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 34 m 16 sec
Reputation Power: 5
You have to eplain what you mean by "doesn't work"

Reply With Quote
  #8  
Old February 26th, 2004, 07:10 AM
vlopes vlopes is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 vlopes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
My ASP Code

Quote:
Originally Posted by frankcow
You have to eplain what you mean by "doesn't work"

Ok my friend

Here is the code I've done at this moment, as you can see there are some lines that are comment.
That me triying and trying to make this thing work.

A send my code in attach
Thank you very much
Attached Files
File Type: txt ASP_CODE.txt (1.7 KB, 759 views)

Reply With Quote
  #9  
Old February 26th, 2004, 08:36 AM
frankcow's Avatar
frankcow frankcow is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: http://www.justin-cook.com
Posts: 133 frankcow User rank is Private First Class (20 - 50 Reputation Level)frankcow User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 34 m 16 sec
Reputation Power: 5
what is the error that you're getting?

Reply With Quote
  #10  
Old February 26th, 2004, 08:43 AM
vlopes vlopes is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 vlopes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by frankcow
what is the error that you're getting?


At this moment, the Excel is openned but empty,
meaning, the array doesn't put in the worksheet the values.

Reply With Quote
  #11  
Old February 26th, 2004, 08:44 AM
frankcow's Avatar
frankcow frankcow is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: http://www.justin-cook.com
Posts: 133 frankcow User rank is Private First Class (20 - 50 Reputation Level)frankcow User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 34 m 16 sec
Reputation Power: 5
try this:
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
'f.Skip(4)

dim MyArray()
dim i
i = 0

do while f.AtEndOfStream = false
Redim Preserve MyArray(i)
MyArray(i) = f.ReadLine
i = i + 1
loop

f.Close
Set f=Nothing
Set fs=Nothing

ShowArrayInTable(MyArray)

Sub ShowArrayInTable(ArrayToShow)

Response.ContentType="application/vnd.ms-excel"

Dim I
Response.Write "<table border=""1"">" & vbCrLf

For I = 0 To UBound(ArrayToShow)
Response.Write "<tr>" & vbCrLf
Response.Write "<td>" & I & "</td>" & vbCrLf
Response.Write "<td>" & replace( ArrayToShow(I), "<", "<") & "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
Next

Response.Write "</table>" & vbCrLf
End Sub
%>

Reply With Quote
  #12  
Old February 26th, 2004, 08:55 AM
vlopes vlopes is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 vlopes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, it works almost good.
The Worksheet only has data when a have a browser of this ASP and a run a Second instance
of the same browser of this ASP.

Is it normal?
What is this?
Response.Write "<td>" & replace( ArrayToShow(I), "<", "<") & "</td>" & vbCrLf

Reply With Quote
  #13  
Old February 26th, 2004, 09:04 AM
frankcow's Avatar
frankcow frankcow is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: http://www.justin-cook.com
Posts: 133 frankcow User rank is Private First Class (20 - 50 Reputation Level)frankcow User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 34 m 16 sec
Reputation Power: 5
I don't understand the question, you can write it in portuguese if you'd like (I think that was the language in your code)

Response.Write "<td>" & replace( ArrayToShow(I), "<", "<") & "</td>" & vbCrLf is just a way of preventing any HTML code in the testread.txt from being formatted by the browser. You don't have to use it if there's no html code

Reply With Quote
  #14  
Old February 26th, 2004, 09:09 AM
vlopes vlopes is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 vlopes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok

Apenas se eu executar duas vezes esta ASP é que o Excel fica preenchido.
A primeira vez que eu executo a ASP mostra um excel vazio e sem dados.
Somente na segunda vez e deixando o outro a aberto é que os dados lá aparecem.


Quote:
Originally Posted by frankcow
I don't understand the question, you can write it in portuguese if you'd like (I think that was the language in your code)

Response.Write "<td>" & replace( ArrayToShow(I), "<", "<") & "</td>" & vbCrLf is just a way of preventing any HTML code in the testread.txt from being formatted by the browser. You don't have to use it if there's no html code

Reply With Quote
  #15  
Old February 26th, 2004, 09:22 AM
frankcow's Avatar
frankcow frankcow is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: http://www.justin-cook.com
Posts: 133 frankcow User rank is Private First Class (20 - 50 Reputation Level)frankcow User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 34 m 16 sec
Reputation Power: 5
this is not normal

I noticed that you had <html> before your ASP code.
You should place ALL of this asp code at the top of the page.

you could even just use this code:

<%
Response.ContentType="application/vnd.ms-excel"

Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)

dim i
i = 0

Response.Write "<table border=""1"">" & vbCrLf

do while f.AtEndOfStream = false
Response.Write "<tr>" & vbCrLf
Response.Write "<td>" & i & "</td>" & vbCrLf
Response.Write "<td>" & f.ReadLine & "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
i = i + 1
loop

Response.Write "</table>" & vbCrLf

f.Close
Set f=Nothing
Set fs=Nothing

%>

use ONLY this code in an .asp page, and see if it works (NO OTHER CODE!!)
then go from there

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherASP Free Lounge > Export data from TextFile to Ms-Excel


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread: