|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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_ |
|
#3
|
|||
|
|||
|
The real problem
Quote:
yes i'm sorry that i have explain the problem badly. I need to do that but using ASP Thanks |
|
#4
|
|||
|
|||
|
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- |
|
#5
|
||||
|
||||
|
set the response type to excel, and open the text file with the FileSystemObject
Response.ContentType = "application/vnd.ms-excel" |
|
#6
|
|||
|
|||
|
Quote:
Hello my Friend I Have done that already and it still doesn't work... |
|
#7
|
||||
|
||||
|
You have to eplain what you mean by "doesn't work"
|
|
#8
|
|||
|
|||
|
My ASP Code
Quote:
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 |
|
#9
|
||||
|
||||
|
what is the error that you're getting?
|
|
#10
|
|||
|
|||
|
Quote:
At this moment, the Excel is openned but empty, meaning, the array doesn't put in the worksheet the values. |
|
#11
|
||||
|
||||
|
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 %> |
|
#12
|
|||
|
|||
|
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 |
|
#13
|
||||
|
||||
|
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 |
|
#14
|
|||
|
|||
|
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:
|
|
#15
|
||||
|
||||
|
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 |
![]() |
| Viewing: ASP Free Forums > Other > ASP Free Lounge > Export data from TextFile to Ms-Excel |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|