Insert multiples table rows into a document with google script -
i developed code allow myself append several rows table under table row cursor inside of.
var ui = documentapp.getui(); var answer = documentapp.getui().prompt("add rows", "insert number of rows want add in box below.\nmake sure have cursor placed in table want append rows to.", documentapp.getui().buttonset.ok_cancel); if(answer.getselectedbutton() == ui.button.ok) { var doc = documentapp.getactivedocument(); var pos = doc.getcursor(); var elementin = pos.getelement(); var tablecell = elementin.getparent(); var tablerow = tablecell.getparent(); var table = tablerow.getparent(); for(var = 0; < answer.getresponsetext(); i++) { var row = table.astable().inserttablerow(table.getchildindex(tablerow)+1); for(var j = 0; j < tablerow.getnumchildren(); j++) { row.inserttablecell(0); } } } doc.saveandclose();
the code executes fine, when try highlight rows created default google table building function table\insert table→
, rows appended program, page freezes , error message of
file unavailable sorry, there's problem file. please reload.
if keeps happening, can report error.
i assume program editing table incorrectly. table displays correct, when attempting highlight original rows , new rows @ same time, freezes.
i agree krr above; there's nothing wrong snippet. there's corrupt document, , need use new one.
you should able make copy of document (file -> make copy...) , copy/paste script new document. if problem follows new doc, you'll have copy/paste entire content document you've created scratch (via "+" button on docs.google.com)
Comments
Post a Comment