Google脚本:在特定位置插入文字

时间:2016-09-09 18:53:08

标签: google-apps-script

这是我的代码:

doc.getBody().editAsText().insertText(0, 'Google').setLinkUrl(0, text.length, 'www.google.com');

这样可以,但会将文本插入页面的最顶层。如何设置我在代码中的位置?

1 个答案:

答案 0 :(得分:0)

找到答案:

$excel = New-Object -ComObject excel.application
$excel.visible = $True
$workbook = $excel.Workbooks.Add()
$workbook.Worksheets.Add()
$Data= $workbook.Worksheets.Item(1)
$Data.Name = 'MySpreadsheet'
$Data.Cells.Item(1,1) = 'Asset Name'
$Data.Cells.Item(1,2) = 'HostName'

# Insert Data   
$Data.Cells.Item(3,1) = "MyAssetName"
$Data.Cells.Item(3,2) = "MyHostName"

# Format, save and quit excel
$usedRange = $Data.UsedRange                                                                                              
$usedRange.EntireColumn.AutoFit() | Out-Null
$workbook.SaveAs("C:\MyExcel.xlsx")
$excel.Quit()