{"id":1163,"date":"2016-02-24T17:51:53","date_gmt":"2016-02-24T09:51:53","guid":{"rendered":"http:\/\/potterdreams.com\/clay\/?page_id=1163"},"modified":"2016-02-24T17:51:53","modified_gmt":"2016-02-24T09:51:53","slug":"how-to-add-command-button","status":"publish","type":"page","link":"https:\/\/potterdreams.com\/clay\/interest\/programmings\/google-script\/how-to-add-command-button\/","title":{"rendered":"How to Add Command Button"},"content":{"rendered":"<p>\/**<br \/>\n* Adds a custom menu to the active spreadsheet, containing a single menu item<br \/>\n* for invoking the readRows() function specified above.<br \/>\n* The onOpen() function, when defined, is automatically invoked whenever the<br \/>\n* spreadsheet is opened.<br \/>\n* For more information on using the Spreadsheet API, see<br \/>\n* https:\/\/developers.google.com\/apps-script\/service_spreadsheet<br \/>\n*\/<br \/>\nfunction onOpen() {<br \/>\nvar spreadsheet = SpreadsheetApp.getActiveSpreadsheet();<br \/>\nvar entries = [{<br \/>\nname : &#8220;Read Data&#8221;,<br \/>\nfunctionName : &#8220;readRows&#8221;<br \/>\n}];<br \/>\nspreadsheet.addMenu(&#8220;Script Center Menu&#8221;, entries);<br \/>\n};<\/p>\n<p>\/**<br \/>\n* Retrieves all the rows in the active spreadsheet that contain data and logs the<br \/>\n* values for each row.<br \/>\n* For more information on using the Spreadsheet API, see<br \/>\n* https:\/\/developers.google.com\/apps-script\/service_spreadsheet<br \/>\n*\/<br \/>\nfunction readRows() {<br \/>\nvar sheet = SpreadsheetApp.getActiveSheet();<br \/>\nvar rows = sheet.getDataRange();<br \/>\nvar numRows = rows.getNumRows();<br \/>\nvar values = rows.getValues();<\/p>\n<p>for (var i = 0; i &lt;= numRows &#8211; 1; i++) {<br \/>\nvar row = values[i];<br \/>\nLogger.log(row);<br \/>\n}<br \/>\n};<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/** * Adds a custom menu to the active spreadsheet, containing a single menu item * for invoking the readRows() function specified above. * The onOpen() function, when defined, is automatically invoked whenever the * spreadsheet is opened. * For &hellip; <a href=\"https:\/\/potterdreams.com\/clay\/interest\/programmings\/google-script\/how-to-add-command-button\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":1161,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-1163","page","type-page","status-publish","hentry"],"jetpack-related-posts":[{"id":1165,"url":"https:\/\/potterdreams.com\/clay\/interest\/programmings\/google-script\/how-to-write-to-a-column-cell\/","url_meta":{"origin":1163,"position":0},"title":"How to Write to A Cell of Last Row","author":"clay","date":"February 24, 2016","format":false,"excerpt":"function fillCols() { var lastRow = SpreadsheetApp.getActiveSpreadsheet().getLastRow(); SpreadsheetApp.getActiveSheet().getRange('V'+lastRow).setValue('English'); }","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":111,"url":"https:\/\/potterdreams.com\/clay\/interest\/programmings\/mysql\/","url_meta":{"origin":1163,"position":1},"title":"MYSQL","author":"clay","date":"April 5, 2012","format":false,"excerpt":"Note: All these based on MySQL 5.1.61 1.\u00a0Find duplicate entries in table SELECT COUNT(*), column1, column2 FROM tablename GROUP BY column1, column2 HAVING COUNT(*)>1; 1b. List Down all the duplicate entries SELECT userid, users.user_ic, useremail, company FROM `users` INNER JOIN (SELECT useric FROM users WHERE useric <> \"\" GROUP BY\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1161,"url":"https:\/\/potterdreams.com\/clay\/interest\/programmings\/google-script\/","url_meta":{"origin":1163,"position":2},"title":"Google Script","author":"clay","date":"February 24, 2016","format":false,"excerpt":"Script Editor","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1453,"url":"https:\/\/potterdreams.com\/clay\/interest\/illustrations\/twice-saved\/","url_meta":{"origin":1163,"position":3},"title":"Twice Saved","author":"clay","date":"March 26, 2018","format":false,"excerpt":"I heard before a story of a young boy who made a beautiful wooden boat, let's call his name Johnny. One day as he was playing with his precious boat in the nearby river, he lost the boat to the current. He jumped to the water, and tried his best\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/pages\/1163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/comments?post=1163"}],"version-history":[{"count":0,"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/pages\/1163\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/pages\/1161"}],"wp:attachment":[{"href":"https:\/\/potterdreams.com\/clay\/wp-json\/wp\/v2\/media?parent=1163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}