{"id":2332,"date":"2008-10-10T05:54:53","date_gmt":"2008-10-10T10:54:53","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2008\/10\/10\/html-tables\/"},"modified":"2016-05-10T08:43:02","modified_gmt":"2016-05-10T12:43:02","slug":"html-tables","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2008\/10\/10\/html-tables\/","title":{"rendered":"HTML tables"},"content":{"rendered":"<div class=\"content\">\r\n\r\nBob's pick this week is a three pack.\r\n\r\n&nbsp;\r\n<div>\r\n<ul>\r\n\t<li><a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18329&amp;objectType=file (link no longer works)\">Display data as an HTML table<\/a> by Gus Brown<\/li>\r\n\t<li><a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=14453&amp;objectType=file (link no longer works)\">Printing Variables to HTML Tables in Published Code<\/a> by Ned Gulley<\/li>\r\n\t<li><a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18687&amp;objectType=file (link no longer works)\">Generate HTML Table with thumbnails from jpg images<\/a> by Theodoros Giannakopoulos<\/li>\r\n<\/ul>\r\n<\/div>\r\nMy work increasingly invloves generating web content for sharing with others. This very post was published from MATLAB which\r\nrelies on HTML! So any clever use of mark-ups to make information more reader friendly is bound to get my attention. <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18329&amp;objectType=file (link no longer works)\">Gus's submission<\/a> is a great example. Not only can it tabulate data it can color it too.\r\n\r\n&nbsp;\r\n\r\nThat's not all. I can use it directly within my MATLAB work flow. To illustrate I'll build on an earlier pick, <tt><a href=\"https:\/\/blogs.mathworks.com\/pick\/2008\/06\/13\/readtext\/\">readtext<\/a><\/tt>. Here's some data: a cell array containing mixed numeric and text values.\r\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">data = readtext(<span style=\"color: #a020f0;\">'SampleData.csv'<\/span>, <span style=\"color: #a020f0;\">'(?m)^''|'',''|''(?m)$'<\/span>);\r\ndata(:,1) = []<\/pre>\r\n<pre style=\"font-style: oblique;\">data = \r\n    'James Murphy'     [471]\r\n    'John Doe, Jr.'    [ 44]\r\n    'Bill O'Brien'     [127]\r\n<\/pre>\r\nTabulate the data.\r\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">disp <span style=\"color: #a020f0;\">&lt;html&gt;<\/span>\r\ndisp(GTHTMLtable(data,{<span style=\"color: #a020f0;\">'Group member'<\/span>,<span style=\"color: #a020f0;\">'Posts'<\/span>}))\r\ndisp <span style=\"color: #a020f0;\">&lt;\/html&gt;<\/span><\/pre>\r\n<table align=\"center\" bgcolor=\"gray\">\r\n<tbody>\r\n<tr>\r\n<th align=\"center\" bgcolor=\"white\">Group member<\/th>\r\n<th align=\"center\" bgcolor=\"white\">Posts<\/th>\r\n<\/tr>\r\n<tr>\r\n<td align=\"right\" bgcolor=\"white\">James Murphy<\/td>\r\n<td align=\"right\" bgcolor=\"white\">471<\/td>\r\n<td align=\"right\" bgcolor=\"white\">John Doe, Jr.<\/td>\r\n<td align=\"right\" bgcolor=\"white\">44<\/td>\r\n<td align=\"right\" bgcolor=\"white\">Bill O'Brien<\/td>\r\n<td align=\"right\" bgcolor=\"white\">127<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nGus's command line help is novel. The \"try it\" callbacks for his examples was a nice touch. His calling syntax offers a lot of flexibility.\r\nWhile it's not exactly in line with how we design functions at The MathWorks, I must say the usability felt good. I found\r\nhis <tt>'show'<\/tt> option, particularly command line friendly.\r\n\r\nMoving on to others, search the File Exchange for \"html table\" and you'll get several hits. I've singled out two more favorites. <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=14453&amp;objectType=file (link no longer works)\">Ned's submission<\/a> includes some wonderful use cases. I really like <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18687&amp;objectType=file (link no longer works)\">Theodoros' thumbnails<\/a> as well.\r\n\r\n<b>Comments?<\/b>\r\n\r\nDo you publish web pages to share your MATLAB work? How do you use HTML? Tell us about it <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2332#respond\">here<\/a>.\r\n\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_707c125f6fff4631b919e3f24b3c7f6b() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='707c125f6fff4631b919e3f24b3c7f6b ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 707c125f6fff4631b919e3f24b3c7f6b';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Robert Bemis';\r\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('\r\n\r\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\r\n\r\n\r\n\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }\r\n\/\/ ]]><\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\">\r\n<a><span style=\"font-size: x-small; font-style: italic;\">Get\r\nthe MATLAB code\r\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a>\r\n\r\nPublished with MATLAB\u00ae 7.7<\/p>\r\n\r\n<\/div>\r\n<!--\r\n707c125f6fff4631b919e3f24b3c7f6b ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectId=969735&objectType=author % Bob>'s pick this week is a three pack.\r\n%%\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18329&objectType=file Display data as an HTML table>\r\n% by Gus Brown\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=14453&objectType=file Printing Variables to HTML Tables in Published Code>\r\n% by Ned Gulley\r\n% * <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18687&objectType=file Generate HTML Table with thumbnails from jpg images>\r\n% by Theodoros Giannakopoulos\r\n%%\r\n% My work increasingly invloves generating web content for sharing with\r\n% others. This very post was published from MATLAB which relies on HTML! So\r\n% any clever use of mark-ups to make information more reader friendly is\r\n% bound to get my attention.\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18329&objectType=file Gus's submission>\r\n% is a great example. Not only can it tabulate data it can color it too.\r\n%%\r\n% https:\/\/www.mathworks.com\/matlabcentral\/files\/18329\/GTHTMLtable.png\r\n%%\r\n% That's not all. I can use it directly within my MATLAB work flow. To\r\n% illustrate I'll build on an earlier pick,\r\n% |<https:\/\/blogs.mathworks.com\/pick\/2008\/06\/13\/readtext\/ readtext>|. Here's\r\n% some data: a cell array containing mixed numeric and text values.\r\ndata = readtext('SampleData.csv', '(?m)^''|'',''|''(?m)$');\r\ndata(:,1) = []\r\n%%\r\n% Tabulate the data.\r\ndisp <html>\r\ndisp(GTHTMLtable(data,{'Group member','Posts'}))\r\ndisp <\/html>\r\n%%\r\n% His command line help is novel. The \"try it\" callbacks for examples was a\r\n% nice touch. His calling syntax offers a lot of flexibility. While it's not\r\n% exactly in line with how we design functions at The MathWorks, I must say\r\n% the usability felt good. I found his |'show'| option, particularly command\r\n% line friendly.\r\n%%\r\n% Moving on to others, search the File Exchange for \"html table\" and you'll\r\n% get\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFileList.do?objectType=search&criteria=html%20table several hits>.\r\n% I've singled out two more favorites.\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=14453&objectType=file Ned's submission>\r\n% includes some wonderful\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/files\/14453\/content\/htmlTables\/html\/htmlTableDemo.html use cases>.\r\n% I really like\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18687&objectType=file Theodoros' thumbnails>\r\n% as well.\r\n\r\n%%\r\n% *Comments?*\r\n%%\r\n% Do you publish web pages to share your MATLAB work? How do you use HTML?\r\n% Tell us about it\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2332#respond here>.\r\n\r\n##### SOURCE END ##### 707c125f6fff4631b919e3f24b3c7f6b\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n\r\nBob's pick this week is a three pack.\r\n\r\n&nbsp;\r\n\r\n\r\n\tDisplay data as an HTML table by Gus Brown\r\n\tPrinting Variables to HTML Tables in Published Code by Ned Gulley\r\n\tGenerate HTML Table with... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2008\/10\/10\/html-tables\/\">read more >><\/a><\/p>","protected":false},"author":46,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2332"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2332"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2332\/revisions"}],"predecessor-version":[{"id":6929,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2332\/revisions\/6929"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}