Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erase content in Google Apps Script Document Service

How to flush a document in Google Apps Script Document Service? Do I need to loop through all the kind of elements e.g. paragraph, image, table and remove them as a child? Is there an easier way to delete everything in the body of a document?

Thank you!

like image 425
user1542330 Avatar asked Jul 21 '12 07:07

user1542330


Video Answer


2 Answers

According to the Documentation, the Document.setText should be able to clear the document content. I assume the following command should do it.

doc.setText('');
like image 82
megabyte1024 Avatar answered Sep 28 '22 08:09

megabyte1024


In the current Document of google apps script as doc.setText method is not available this could be achieved by doc.getBody().clear()

like image 23
Riyafa Abdul Hameed Avatar answered Sep 28 '22 07:09

Riyafa Abdul Hameed