小编car*_*g97的帖子

如何在 Google 表格中使用 .gs 脚本打印工作表/范围?

我正在尝试在 Google Sheets 中创建一个脚本来选择一个范围并打印它。我正在尝试根据一些参数打印一些信息。我有以下脚本来设置所需的范围,但我没有找到使用脚本打印它的方法。

function printInvoice() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var range = sheet.getRange("A1:H46");

  range.activate();
}
Run Code Online (Sandbox Code Playgroud)

有什么建议么?谢谢!

google-sheets google-sheets-api

9
推荐指数
1
解决办法
3万
查看次数

如何刷新存储的Google oAuth凭据

我正在使用谷歌提供的Python API.我想要做的只是确保访问令牌不会过期.我将refresh_token存储在凭证文件中.我只是不确定如何在调用API之前"检查"令牌仍然是好的,如果需要刷新它并将其重新存储在凭证文件中.

我做了一个测试,即使我从凭证文件中删除了使用刷新令牌将其重写为凭证的访问令牌.我希望这也适用于过期的访问令牌.

谢谢

storage = Storage('cred_storage.txt')

credentials = storage.get()

if not credentials:
    flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI)
    authorize_url = flow.step1_get_authorize_url()
    print 'Go to the following link in your browser: ' + authorize_url
    code = raw_input('Enter verification code: ').strip()
    credentials = flow.step2_exchange(code)
    storage.put(credentials)


http = httplib2.Http()
http = credentials.authorize(http)
print http
service = build('admin', 'reports_v1', http=http)
print service
data_query = service.customerUsageReports().get(**{'date':'2015-01-07'})
feed = data_query.execute()
print feed
Run Code Online (Sandbox Code Playgroud)

python access-token google-oauth

2
推荐指数
2
解决办法
2216
查看次数