读取文本文件并在表格 vbscript 中显示 [英] Read text file and show in table vbscript
本文介绍了读取文本文件并在表格 vbscript 中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个具有以下结构的文本文件:-
I have a text file with following structure :-
C:UsersabcDesktopNew Foldersample.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
queryName->abc
queryName->def
next
C:UsersabcDesktopNew FolderNew foldersample3.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
AccountName->Names
AccountName->prelLayer
queryAccount->serchTerm
queryName->myName1
next
C:UsersabcDesktopNew Foldersample1.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
next
C:UsersabcDesktopNew Foldersample2.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
queryName->abc
queryName->def
AccountName->Names
AccountName->prelLayer
queryAccount->serchTerm
queryName->myName1
next
我必须使用 vbscript 在网页上以表格格式显示此信息.表格应该是这样的:-
I have to show this information in tabular format on a webpage using vbscript. The table should be like:-
+------+--------------+--------------+--------------+-----------+
| Path | AccountName1 | AccountName2 | QueryAccount | QueryName |
+------+--------------+--------------+--------------+-----------+
|C:...| AbcPos | dblLayer | qskxyz | qixyz |
+------+--------------+--------------+--------------+-----------+
|C:...| AbcPos | dblLayer | qskxyz | abc |
+------+--------------+--------------+--------------+-----------+
|C:...| AbcPos | dblLayer | qskxyz | def |
+------+--------------+--------------+--------------+-----------+
|C:3..| AbcPos | dblLayer | qskxyz | qixyz |
+------+--------------+--------------+--------------+-----------+
|C:3..| Names | prelLayer | qskxyz | abc |
+------+--------------+--------------+--------------+-----------+
|C:3..| AbcPos | dblLayer | searchTerm | myName1 |
+------+--------------+--------------+--------------+-----------+
目前我只是用 vbscript 读取文本文件,但需要以表格格式显示.
Currently I am just reading text file with vbscript but need to show it in tabular format.
Set dict = CreateObject("Scripting.Dictionary")
Set file = fso.OpenTextFile ("c: est.txt", 1)
row = 0
Do Until file.AtEndOfStream
line = file.Readline
dict.Add row, line
row = row + 1
Loop
file.Close
我无法在此处发布我的完整代码,因为我无法从我的环境中复制.
I can not post my complete code here as I am not able to copy from my environment.
推荐答案
我的实现是这样的:-
Set mytable=document.CreateElement("table")
set thead = document.createElement("thead")
set tr=document.createElement("tr")
set th1=document.createElement("th")
th1.setattribute "colSpan","4"
tr.appendChild th1
thead.appendChild tr
set tr2= document.createElement("tr")
set th1= document.createElement("th")
set th2= document.createElement("th")
set th3= document.createElement("th")
set th4= document.createElement("th")
set th5= document.createElement("th")
th1.innerText="AccountName1"
th2.innerText="AccoutnName2"
th3.innerText="QueryAccount"
th4.innerText="QueryName"
th5.innerText="Path/Location"
tr2.appendChild th1
tr2.appendChild th2
tr2.appendChild th3
tr2.appendChild th4
tr2.appendChild th5
thead.appendChild tr2
mytable.appendChild thead
.......................
.......................
For Each thing in Fls
......................
........................
set td1 = document.createElement("td")
set td2 = document.createElement("td")
set td3 = document.createElement("td")
set td4 = document.createElement("td")
set td5 = document.createElement("td")
if condition
set tr3=document.createElement("tr")
td1.innerText=nodeinfo(0)
td2.innerText=nodeinfo(1)
td3.innerText=nodeinfo(2)
td4.innerText=node.text
td5.innerHtml="<a href=" & "'" & thing.Path & "'" & ">" & thing.Path &"</a>"
tr3.appendChild td1
tr3.appendChild td2
tr3.appendChild td3
tr3.appendChild td4
tr3.appendChild td5
tbod.appendChild tr3
elseif i=2 then
set tr3=document.createElement("tr")
td1.innerText="--"
td2.innerText=nodeinfo(0)
td3.innerText=nodeinfo(1)
td4.innerText=node.text
td5.innerHtml="<a href=" & "'" & thing.Path & "'" & ">" & thing.Path &"</a>"
tr3.appendChild td1
tr3.appendChild td2
tr3.appendChild td3
tr3.appendChild td4
tr3.appendChild td5
tbod.appendChild tr3
elseif i=1 then
set tr3=document.createElement("tr")
td1.innerText="--"
td2.innerText="--"
td3.innerText=nodeinfo(0)
td4.innerText=node.text
td5.innerHtml="<a href=" & "'" & thing.Path & "'" & ">" & thing.Path &"</a>"
tr3.appendChild td1
tr3.appendChild td2
tr3.appendChild td3
tr3.appendChild td4
tr3.appendChild td5
tbod.appendChild tr3
这篇关于读取文本文件并在表格 vbscript 中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文