How can I copy a range of a Sheet into a Doc, which I created in AppScript Editor.
Like this(Manually copied(CtrlC + CtrlV))
对不起,我的英语不好。
这是可以做到的。
Imagine your spreadsheet is this:
在文档的脚本编辑器上编写以下代码,
function readFromSpreadsheetAndWriteOnDoc()
{
// get the Spreadsheet by sheet id
var source = SpreadsheetApp.openById('1eqaThzYmTbZzP_xGTrPnTD1JX-B8rXrBrWDW8DwMNeU');
// select the sheet
var sourcesheet = source.getSheetByName('Chart');
// get the values on selectd range
var srcData = sourcesheet.getRange('B2:C5').getValues();
//now your table data is on var 'srcData'
// select this google doc
var doc = DocumentApp.getActiveDocument();
// select the body
var body = doc.getBody();
body.insertParagraph(0, 'My Title').setHeading(DocumentApp.ParagraphHeading.HEADING1).setAlignment(DocumentApp.HorizontalAlignment.CENTER);
table = body.appendTable(srcData);
table.getRow(0).editAsText().setBold(true);
}