Is there a Google Sheets library so I can read a spreadsheet?

blov · 2015-06-05 00:49:52 · 773 次点击    
这是一个分享于 2015-06-05 00:49:52 的资源,其中的信息可能已经有所发展或是发生改变。

The best I can come up with is the Google API client, which does not seem to support docs. I just need to grab some values from a spreadsheet (no writing). If there isn't a library, any hints on how to authenticate w/ OAuth2 in Go? Also, the following seems to result in an invalid SSL certificate:

   tr := &http.Transport{
    TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
resp, err := client.Get("https://spreadsheets.google.com/feeds/cells/myid/1/private/full")
if err != nil {
    panic(err)
}
r, _ := json.MarshalIndent(resp, "", "    ")
log.Println(string(r))  // json telling me about an invalid certificate

**评论:**

anoland:

It appears that you can still get spreadsheet data as json,

If your spreadsheet is published to the web all you have to do is add alt=json to the url in order to use the data in JSON format. Example: https://spreadsheets.google.com/feeds/list/1HGVmKJJ_W5p-SEbzLTRM4p5v_al9XC7yyjmTlbRtGAk/od6/public/basic?hl=en_US&alt=json

If it isn't but you think you can get access to the non-published version using Oauth2 then there is a google Oauth2 client that you would use to get around that restriction. I've never tried what I'm suggesting, but it makes sense that you would have to do that.

This may help you get the oauth client you need. http://golangtutorials.blogspot.com/2011/11/oauth2-3-legged-authorization-in-go-web.html

fsdfsdjflkdsjfsdklj:

Is using it without OAuth2 going to be deprecated? https://developers.google.com/gdata/samples/spreadsheet_sample

anoland:

Only google knows.

nate510:

Have you looked here and here?

fsdfsdjflkdsjfsdklj:

For the OAuth2 part, is that what you mean?

EDIT: I didn't see a way to read a spreadsheet.

nate510:

Ah, yeah, I guess those APIs are for manipulating files and not for parsing them. Looks like only Java and .NET clients are maintained by Google.

Sorry, couldn't find anything in Go to do what you're asking.

tealeg:

If you only want to read the content of the spreadsheet, then you could download it in XLSX format and use xlsx to read it.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

773 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传