bourny Posted January 14, 2016 Share Posted January 14, 2016 I am trying to take an array and feed this into the body of an email which I am building up ready to be sent out. I have seen some examples in the forum but is usually taking html to array etc the other way round. I have the email includes I need to generate the email just struggling to see an easy way of generating a table from an array.Any ideas or examples of anyone doing something similar. I will start working on writing the html code from scratch if there is noting out in the forum. Many thanks Link to comment Share on other sites More sharing options...
jdelaney Posted January 14, 2016 Share Posted January 14, 2016 (edited) Just loop through your array (use a for loop within a for loop) and construct a string. Add the prefix of the <tr> prior to entering the inner for loop, </tr> after exiting the inner for loop, <td> before outputting the inner for loop...etc etc...outside of both loops, add in the <table> </table>. Give it a go. You can get tricky and add a header <th> on the first inner loop. Edited January 14, 2016 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Danyfirex Posted January 14, 2016 Share Posted January 14, 2016 (edited) I wrote this just for fun.#include <Array.au3> Local $aArray[4][4] For $f = 0 To 3 For $c = 0 To 3 $aArray[$f][$c] = "$aArray[" & $f & "][" & $c & "]" Next Next _ArrayDisplay($aArray) Local $sHtmlTable = _CreateTableFrom2DArray($aArray) FileWrite("TestTable.html", $sHtmlTable) ShellExecute("TestTable.html") Func _CreateTableFrom2DArray($aArray) Local $sTable = '<table border="1">' & @CRLF For $f = 0 To UBound($aArray, 1) - 1 $sTable &= '<tr>' & @CRLF For $c = 0 To UBound($aArray, 2) - 1 $sTable &= '<td>' $sTable &= $aArray[$f][$c] ConsoleWrite($aArray[$f][$c] & @TAB) $sTable &= '</td>' & @CRLF Next $sTable &= '</tr>' & @CRLF ConsoleWrite(@CRLF) Next $sTable &= '</table>' Return $sTable EndFunc ;==>_CreateTableFrom2DArrayI also found this over the forum Saludos Edited January 14, 2016 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
bourny Posted January 14, 2016 Author Share Posted January 14, 2016 Thanks alljdelaney: That is exactly what i was planning to start writing if there was no now udf`s already in use for this purpose. Danyfirex: Impressive speed on what would have took be half a day to write something similar. I will post back what I come up with as my final email body with decent formatting etc so the table looks a bit prettier.Many thanks for your time and help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now