我有一个简单的任务要做,但我不知道VB。我有excel文件结构如下:
ID | File name | Title
-------------------------------
1 | 1.mim | ABC Song
2 | 2.mim | Five little monkeys
3 | 3.mim | Counting bananas
我需要在下面的表单中生成excel文件的文本输出:
<li>
<a href="#" onclick="window.plugins.videoPlayer.play('file:///storage/emulated/0/nepal/%id%.mim');">
<img src="img/radiologo/%id%.jpg" alt="" />
<div class="channel-info">
<h1>%Title%</h1>
</div>
</a>
</li>
请你帮我解决这个问题:)
答案 0 :(得分:0)
确定已解决,此处是以下代码
Sub main()
Dim fs As Object, f As Object, i As Integer
Set fs = CreateObject("Scripting.FileSystemObject")
Call createFile(f, fs, "Z:\Tablets\output.html")
i = 2
While Cells(i, 1) <> ""
Call writeTab(f, 2, "<li>")
Call writeTab(f, 3, "<a href=""#"" onclick=""window.plugins.videoPlayer.play('file:///storage/emulated/0/nepal/" & Cells(i, 1) & ".mim');"">")
Call writeTab(f, 4, "<img src=""img/icons/" & Cells(i, 1) & ".jpg"" alt="""" />")
Call writeTab(f, 4, "<div class=""channel-info"">")
Call writeTab(f, 5, "<h1>" & Cells(i, 4) & "</h1>")
Call writeTab(f, 4, "</div>")
Call writeTab(f, 3, "</a>")
Call writeTab(f, 2, "</li>")
i = i + 1
Wend
Set f = Nothing: Set fs = Nothing
End Sub
Sub createFile(fileObject As Object, fso As Object, fileName As String, Optional utf16 As Integer = 0)
Set fileObject = fso.opentextfile(fileName, 2, True, utf16)
End Sub
Sub writeTab(f As Object, ByVal t As Integer, ByVal s As String)
Dim tabString As String, i As Integer
For i = 1 To t
tabString = tabString & Chr(9)
Next i
f.writeline tabString & s
End Sub