答案 0 :(得分:3)
可以这样做。
在doc的脚本编辑器上写下以下代码,
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);
}
你会得到这个,
享受!