本文介绍了将一系列SpreadSheet复制到Doc中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何复制图纸的范围。
像这样(手动复制(CtrlC + CtrlV))
对不起,我的英文不好。
解决方案
这是可以做到的。
$ b
想象一下您的电子表格是这样的:
写下面的代码在doc的脚本编辑器中,
function readFromSpreadsheetAndWriteOnDoc()
{
//获取Spreadsheet by图片ID
var source = SpreadsheetApp.openById('1eqaThzYmTbZzP_xGTrPnTD1JX-B8rXrBrWDW8DwMNeU');
//选择图表
var sourcesheet = source.getSheetByName('Chart');
//获取选定范围的值
var srcData = sourcesheet.getRange('B2:C5')。getValues();
//现在你的表数据在var'srcData'
//选择这个google文档
var doc = DocumentApp.getActiveDocument();
//选择正文
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);
}
你会得到这个,
享受!
How can I copy a range of a Sheet into a Doc, which I created in AppScript Editor.
Like this(Manually copied(CtrlC + CtrlV))
Sorry for my bad English.
解决方案
This is can be done.
Imagine your spreadsheet is this:
Write below code on doc's script editor,
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);
}
you will get this,
Enjoy!
这篇关于将一系列SpreadSheet复制到Doc中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!