HTML & Table Erstellung

  • VB.NET
  • .NET (FX) 4.5–4.8

Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von woeh.

    HTML & Table Erstellung

    hallo :)

    ich laße eine tabelle erstellen und kopiere diese aneinander.
    das funktioniert auch ganz gut, bis irgendwann nur noch chaos rauskommt.

    wenn ich mir der quellcode in firefox ansehe, wird der quellcode ganz normal angezeigt.

    hier mein code:

    VB.NET-Quellcode

    1. Public Sub CreateHtmlPlaylist(ByVal saveFile As String,
    2. ByVal fileList() As String,
    3. ByVal sourcePath As String,
    4. ByVal tmpFile As String)
    5. Dim tag As TagLib.Tag
    6. Dim mp3 As TagLib.File
    7. Dim htmlDir As String, dir As String, file As String
    8. Dim artistLink As String, albumLink As String, youTubeLink As String
    9. Dim allPlayTime As Double, playTime As Double
    10. Dim allBytes As Double, fileBytes As Double
    11. Dim p As UInteger
    12. On Error GoTo Quit
    13. If mainform.chkPlayListOnlyOnePlaylist.Checked = True Then
    14. saveFile = IO.Path.GetTempFileName
    15. End If
    16. Dim enc As Text.Encoding = Text.Encoding.UTF8
    17. Dim fPL As IO.StreamWriter = New IO.StreamWriter(saveFile, False, enc)
    18. dir = sourcePath
    19. htmlDir = Replace(dir, "\", "/")
    20. fPL.WriteLine("<!DOCTYPE HTML>")
    21. fPL.WriteLine("<head>")
    22. fPL.WriteLine("<meta charset = ""utf-8"">")
    23. fPL.WriteLine("<title>File Overview</title>")
    24. fPL.WriteLine("<style type = ""text/css"" > <!--")
    25. fPL.WriteLine(".s0 {")
    26. fPL.WriteLine("Font - family: tahoma;")
    27. fPL.WriteLine("Font-Size: 12px;")
    28. fPL.WriteLine("color: #000000; font-style: normal;")
    29. fPL.WriteLine("background-Color: transparent;")
    30. fPL.WriteLine("Text-align: Left();")
    31. fPL.WriteLine("}")
    32. fPL.WriteLine(".s1 {")
    33. fPL.WriteLine("Font - family: tahoma;")
    34. fPL.WriteLine("Font-Size: 12px;")
    35. fPL.WriteLine("color: #FFFFFF; font-style: normal;")
    36. fPL.WriteLine("background-Color: transparent;")
    37. fPL.WriteLine("Text-align: Left();")
    38. fPL.WriteLine("}")
    39. fPL.WriteLine("--></style>")
    40. fPL.WriteLine("</head><body leftmargin=50 bgcolor=""black"" link=""red"" alink=""red"" vlink=""red"">")
    41. fPL.WriteLine("<hr><font face=""tahoma"" size=4><Center><a href=""file://" & htmlDir & """>" & GetLastFolder(dir, False) & "</a></Center></font><hr>")
    42. fPL.WriteLine("<font color=""yellow"">")
    43. fPL.WriteLine("<table style = ""width:100%"">")
    44. fPL.WriteLine("<tr><td style=""font-weight: bold"">Dateiname</td><td style=""font-weight: bold"">Größe</td><td style=""font-weight: bold"">Länge</td><td style=""font-weight:bold"">Track</td><td style=""font-weight:bold"">Title</td><td style=""font-weight:bold"">Artist</td><td style=""font-weight:bold"">Album</td><td style=""font-weight:bold"">Genre</td></tr>")
    45. Dim sourceFile As String
    46. For p = 0 To fileList.Length - 1
    47. file = fileList(p)
    48. If mainform.chkPlayListFileOptionFullFilePath.Checked = False Then
    49. sourceFile = clsClass.GetPath(dir) & file
    50. Else
    51. sourceFile = file
    52. End If
    53. If mainform.rbPlayListReadID3v1.Checked = True Then
    54. ID3v1GetTag(sourceFile, mp3, tag)
    55. End If
    56. If mainform.rbPlayListReadID3v2.Checked = True Then
    57. ID3v2GetTag(sourceFile, mp3, tag)
    58. End If
    59. playTime = mp3.Properties.Duration.Minutes & "," & mp3.Properties.Duration.Seconds
    60. allPlayTime = allPlayTime + playTime
    61. fileBytes = FileLen(sourceFile)
    62. allBytes = allBytes + fileBytes
    63. artistLink = Link_GetArtistLink(tag.FirstArtist)
    64. albumLink = tag.FirstArtist & " - " & tag.Album
    65. albumLink = Net.WebUtility.UrlEncode(albumLink)
    66. albumLink = "https://www.last.fm/search/albums?q=" & albumLink
    67. youTubeLink = Link_GetYouTubeLink(tag.FirstArtist, tag.Title)
    68. fPL.WriteLine("<td class=""s0""><a href = ""file://" & sourceFile.Replace("\", "/") & """ target=""_blank"">" & IO.Path.GetFileNameWithoutExtension(sourceFile) & "</a></td>")
    69. fPL.WriteLine("<td class=""s1"">" & FormatBytes(fileBytes) & "</td>")
    70. fPL.WriteLine("<td class=""s1"">" & playTime.ToString & "</td>")
    71. fPL.WriteLine("<td class=""s1"">" & tag.Track.ToString & "</td>")
    72. fPL.WriteLine("<td class=""s0"">" & "<a href = """ & youTubeLink & """ target=""_blank"">" & tag.Title & "</td>")
    73. fPL.WriteLine("<td class=""s0""><a href = """ & artistLink & """ target=""_blank"">" & tag.FirstArtist & "</td>")
    74. fPL.WriteLine("<td class=""s0""><a href = """ & albumLink & """ target=""_blank"">" & tag.Album & "</td>")
    75. fPL.WriteLine("<td class=""s1"">" & tag.FirstGenre & "</td></tr>")
    76. Next p
    77. Quit:
    78. allPlayTime = Math.Round(allPlayTime / 60, 2)
    79. fPL.WriteLine("</table><hr><hr>")
    80. fPL.WriteLine("<p>" & fileList.Length.ToString & " Dateien " &
    81. "(" & FormatBytes(allBytes) & ") " &
    82. "(" & allPlayTime.ToString & "h Spielzeit)</p>")
    83. fPL.WriteLine("</body>")
    84. fPL.WriteLine("</html>")
    85. fPL.Close()
    86. If tmpFile IsNot Nothing Then
    87. Dim r As String = Text_ReadFile(saveFile)
    88. clsClass.Text_WriteTotFile(tmpFile, r)
    89. End If
    90. If mainform.chkPlayListOnlyOnePlaylist.Checked = True Then
    91. KillFile(saveFile, False)
    92. End If
    93. End Sub


    hat jmd ne idee ?
    Option Strict Off + VisualBasic-Namespace + zahlreiche Aufrufe, die auf Funktionen verweisen, die wohl keiner von uns außer Dir hat. Na herzlichen Dank.
    Nachdem ich vieles davon eingedampft hatte und den Code mit leeren Testdateien gefüttert hatte, kam ich auf u.g. Screenshot. Scheint zu passen.
    Bilder
    • Screenshot.png

      11,9 kB, 1.440×218, 93 mal angesehen
    Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von „VaporiZed“, mal wieder aus Grammatikgründen.

    Aufgrund spontaner Selbsteintrübung sind all meine Glaskugeln beim Hersteller. Lasst mich daher bitte nicht den Spekulatiusbackmodus wechseln.
    naja....die funktionen holen sich nur die taginfos, dateinamen, größe und links und schreiben das als links in die tabelle. das komische ist eben, dass iwann nur noch blödsinn rauskommt.

    wie gesagt...schau ich mir den quellcode dann in firefox an, ist alles ganz normal

    ich kann mir keinen reim darauf machen....habe auch mal in nen HTML-forum gefragt
    Bilder
    • OK.jpg

      222,94 kB, 1.007×560, 94 mal angesehen
    • Hier wirds dann nix mehr.jpg

      280,38 kB, 1.024×588, 96 mal angesehen
    • so wirds dann.jpg

      504,1 kB, 1.007×560, 98 mal angesehen