AppleScript名:listからHTML Tableの生成 v2 |
— Created 2017-02-24 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set aList to {{"1", "2", "3"}, {"3", "4", "5"}, {"5", "6", "7"}} set aHeader to "<html><head><title>First</title><style>table , td, table , tr, th{border:1px solid #333333;padding:2px;}</style></head><body><table ><tr><th>Col1</th><th>Col2</th><th>Col3</th><th>Col4</th><th>Col5</th></tr>" set aTable to "<tr><td>%@</td><td> </td><td>%@</td><td>%@</td><td>%@</td></tr>" set aFooter to "</table></body></html>" set aHTMLres to retTableHTML(aList, aHeader, aTable, aFooter) of me on retTableHTML(aList, aHeaderHTML, aTableHTML, aFooterHTML) set allHTML to current application’s NSMutableString’s stringWithString:aHeaderHTML set aCounter to 1 repeat with i in aList set j to contents of i set tmpList to (current application’s NSArray’s arrayWithArray:j) set aRowHTML to current application’s NSString’s stringWithFormat_(aTableHTML, (aCounter as string), tmpList’s objectAtIndex:0, tmpList’s objectAtIndex:1, tmpList’s objectAtIndex:2) (allHTML’s appendString:aRowHTML) set aCounter to aCounter + 1 end repeat (allHTML’s appendString:aFooterHTML) allHTML end retTableHTML |
More from my site
(Visited 29 times, 1 visits today)