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:
  #1  
Old February 25th, 2004, 11: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, 811 views)

Reply With Quote
  #2  
Old February 25th, 2004, 11: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: 14
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, 11: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, 11: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: 14
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, 12:41 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: 6
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, 01: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, 05: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: 6
You have to eplain what you mean by "doesn't work"

Reply With Quote
  #8  
Old February 26th, 2004, 08: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, 961 views)

Reply With Quote
  #9  
Old February 26th, 2004, 09: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: 6
what is the error that you're getting?

Reply With Quote
  #10  
Old February 26th, 2004, 09: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, 09: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: 6
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, 09: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, 10: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: 6
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, 10: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, 10: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: 6
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:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek