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

blov · · 612 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>The best I can come up with is the <a href="https://github.com/google/google-api-go-client">Google API client</a>, which does not seem to support docs. I just need to grab some values from a spreadsheet (no writing). If there isn&#39;t a library, any hints on how to authenticate w/ OAuth2 in Go? Also, the following seems to result in an invalid SSL certificate:</p> <pre><code> tr := &amp;http.Transport{ TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true}, } client := &amp;http.Client{Transport: tr} resp, err := client.Get(&#34;https://spreadsheets.google.com/feeds/cells/myid/1/private/full&#34;) if err != nil { panic(err) } r, _ := json.MarshalIndent(resp, &#34;&#34;, &#34; &#34;) log.Println(string(r)) // json telling me about an invalid certificate </code></pre> <hr/>**评论:**<br/><br/>anoland: <pre><p><a href="https://developers.google.com/gdata/docs/directory" rel="nofollow">It appears that you can still</a> get <a href="https://developers.google.com/gdata/samples/spreadsheet_sample" rel="nofollow">spreadsheet data as json</a>,</p> <p>If your spreadsheet is published to the web all you have to do is add <code>alt=json</code> to the url in order to use the data in JSON format. Example: <a href="https://spreadsheets.google.com/feeds/list/1HGVmKJJ_W5p-SEbzLTRM4p5v_al9XC7yyjmTlbRtGAk/od6/public/basic?hl=en_US&amp;alt=json" rel="nofollow">https://spreadsheets.google.com/feeds/list/1HGVmKJJ_W5p-SEbzLTRM4p5v_al9XC7yyjmTlbRtGAk/od6/public/basic?hl=en_US&amp;alt=json</a></p> <p>If it isn&#39;t but you think you can get access to the non-published version using Oauth2 then there is a <a href="http://godoc.org/golang.org/x/oauth2/google" rel="nofollow">google Oauth2 client</a> that you would use to get around that restriction. I&#39;ve never tried what I&#39;m suggesting, but it makes sense that you would have to do that.</p> <p>This may help you get the oauth client you need. <a href="http://golangtutorials.blogspot.com/2011/11/oauth2-3-legged-authorization-in-go-web.html" rel="nofollow">http://golangtutorials.blogspot.com/2011/11/oauth2-3-legged-authorization-in-go-web.html</a></p></pre>fsdfsdjflkdsjfsdklj: <pre><p>Is using it without OAuth2 going to be deprecated? <a href="https://developers.google.com/gdata/samples/spreadsheet_sample" rel="nofollow">https://developers.google.com/gdata/samples/spreadsheet_sample</a></p></pre>anoland: <pre><p>Only google knows.</p></pre>nate510: <pre><p>Have you looked <a href="https://github.com/google/google-api-go-client/blob/master/examples/drive.go" rel="nofollow">here</a> and <a href="https://developers.google.com/drive/v2/reference/files/get" rel="nofollow">here</a>?</p></pre>fsdfsdjflkdsjfsdklj: <pre><p>For the OAuth2 part, is that what you mean?</p> <p>EDIT: I didn&#39;t see a way to read a spreadsheet.</p></pre>nate510: <pre><p>Ah, yeah, I guess those APIs are for manipulating files and not for parsing them. Looks like only <a href="https://developers.google.com/google-apps/spreadsheets/index" rel="nofollow">Java and .NET clients are maintained by Google</a>.</p> <p>Sorry, couldn&#39;t find anything in Go to do what you&#39;re asking. </p></pre>tealeg: <pre><p>If you only want to read the content of the spreadsheet, then you could download it in XLSX format and use <a href="https://github.com/tealeg/xlsx" rel="nofollow">xlsx</a> to read it.</p></pre>

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

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