Tabelle in html schreiben

  • hallo...gibts irgendeine udf welche bestimmte werte in eine tabelle schreibt?
    am besten wäre html da es sein kann das manche kein excel haben.

  • Hatte da noch was rumliegen:

    Spoiler anzeigen
    [autoit]

    Global $a[3][3] = [['1','2','3'],['1.1','1.2','1.3'],['2.1','2.2','2.3']]

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite(_ArrayToHTMLTable($a,true,false))

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ===================================================================
    ; Name ..........: _ArrayToHTMLTable
    ; Description ...: Creates a HTML-table from a 2dim-array
    ; AutoIt Version : V3.3.0.0
    ; Syntax ........: _ArrayToHTMLTable(ByRef $aArray[, $bHeader = True[, $bBorder = True[, $sStyle = 'width:100%']]])
    ; Parameter(s): .: $aArray -
    ; $bHeader - Optional: (Default = True) :
    ; $bBorder - Optional: (Default = True) :
    ; $sStyle - Optional: (Default = width: 100%) : StyleSheet
    ; Return Value ..: Success - string
    ; Failure - empty string
    ; @ERROR -
    ; Author(s) .....: Thorsten Willert
    ; Date ..........: Wed Jul 01 18:07:39 CEST 2009
    ; Version .......: 1.0
    ; ==============================================================================
    Func _ArrayToHTMLTable(ByRef $aArray, $bHeader = True, $bBorder = True, $sStyle = 'width:100%')
    Local $iD1 = UBound($aArray,1)
    If @error Then
    SetError(1)
    Return ''
    EndIf
    Local $iD2 = UBound($aArray,2)
    If @error Then
    SetError(1)
    Return ''
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $sTable = ""
    If $sStyle <> '' Then $sStyle = ' style="' & $sStyle & '"'
    $sStyle &= '>'

    [/autoit] [autoit][/autoit] [autoit]

    If $bBorder Then
    $sTable &= '<table border="1"'
    Else
    $sTable &= '<table'
    EndIf
    $sTable &= $sStyle & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    Local $iStart = 0
    If $bHeader Then
    $iStart = 1
    $sTable &= '<tr>' & @CRLF
    For $i = 0 To $iD2 -1
    $sTable &= @TAB & '<th>' & $aArray[0][$i] & '</th>' & @CRLF
    Next
    $sTable &= '</tr>' & @CRLF
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    For $i = $iStart To $iD1 -1
    $sTable &= '<tr>' & @CRLF
    For $j = 0 To $iD2 -1
    $sTable &= @TAB & '<td>' & $aArray[$i][$j] & '</td>' & @CRLF
    Next
    $sTable &= '</tr>' & @CRLF
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $sTable &= '</table>' & @CRLF

    [/autoit] [autoit][/autoit] [autoit]

    Return $sTable
    EndFunc ;==> _ArrayToHTMLTable

    [/autoit]

    die Rückgabe ist allerdings keine vollwertige HTML-Datei sondern nur die Tabelle. Zeigt allerdings jeder Browser auch so an.

  • ja das mit filewrite ist ziemlich aufwändig...

    ich würde es gerne so machen dass die erste zeile schonmal vordefiniert ist, auch so von breite der einzelnen zellen...
    dann soll mein skript eine zahl auslesen, wenn sie zb 3 ist, soll unter die erste zeile nochmal zweimal die gleiche zeile..versteht ihr?

  • Da fehlt auch nicht viel.
    Oben noch ein

    HTML
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <title>Tabelle in HTML</title>
      </head>
      <body>
        <!-- Hier die Tabelle hinein //-->
      </body>
    </html>

    Und das war jetzt auswendig ;)

  • hehe so doof bin a net...
    html grundlagen kann ich auch^^
    hab jetz in excel eine gemacht und als website gespeichert...da werde ich dann ein bisschen rumtüfteln...blöden office websites sind immer so dumm aufgebaut!!