用于 Google 电子表格 CSV 导出的下载链接 - 带有多张表格 [英] Download link for Google Spreadsheets CSV export - with Multiple Sheets

查看:23
本文介绍了用于 Google 电子表格 CSV 导出的下载链接 - 带有多张表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找一个链接,该链接允许我下载 Google 电子表格的 CSV 格式版本.目前我正在使用:

https://docs.google.com/spreadsheets/d/DOCID/export?format=csv

这很好用,只是它只下载第一个工作表.我的文档有多张纸.有谁知道如何设置此链接的格式,以便下载所有工作表或特定工作表?类似的东西:

&sheet=all

&sheet=3

解决方案

Google 表格中的每个文档都支持图表工具数据源协议",这些文章(以一种相当随意的方式)对此进行了解释:

  1. 从单独的电子表格创建图表"
  2. 查询语言参考"
  3. 实施图表工具数据源协议"

要将特定工作表下载为 CSV 文件,请将 {key} 替换为文档的 ID,将 {sheet_name} 替换为要导出的工作表的名称:

https://docs.google.com/spreadsheets/d/{key}/gviz/tq?tqx=out:csv&sheet={sheet_name}

数据源协议非常灵活.其他各种选项包括:

响应格式: 选项包括 tqx=out:csv(CSV 格式)、tqx=out:html(HTML 表格)和tqx=out:json(JSON 数据).

导出工作表的一部分: 提供 range={range} 选项,其中范围可以是任何有效的范围说明符,例如A1:C99B2:F.

执行 SQL 查询: 提供 tq={query} 选项,例如 tq=SELECT a, b, (d+e)*2哪里 c <100 AND x = 'yes'.

导出文本数据:如果您的字段包含文本数据,请提供 headers=0 选项,否则它们可能会在导出过程中被删除.

I'm trying to find a link which allows me to download a CSV formatted version of my Google Spreadsheet. Currently I'm using:

https://docs.google.com/spreadsheets/d/DOCID/export?format=csv

This works great except that it only download the first Sheet. My document has multiple sheets. Does anyone know how to format this link so that it downloads either all the sheets or a specific sheet? Something like:

&sheet=all

or

&sheet=3

解决方案

Every document in Google Sheets supports the "Chart Tools datasource protocol", which is explained (in a rather haphazard way) in these articles:

  1. "Creating a Chart from a Separate Spreadsheet"
  2. "Query Language Reference"
  3. "Implementing the Chart Tools Datasource Protocol"

To download a specific sheet as a CSV file, replace {key} with the document's ID and {sheet_name} with the name of the sheet to export:

https://docs.google.com/spreadsheets/d/{key}/gviz/tq?tqx=out:csv&sheet={sheet_name}

The datasource protocol is quite flexible. Various other options include:

Response Format: Options include tqx=out:csv (CSV format), tqx=out:html (HTML table), and tqx=out:json (JSON data).

Export part of a sheet: Supply the range={range} option, where the range can be any valid range specifier, e.g. A1:C99 or B2:F.

Execute a SQL query: Supply the tq={query} option, such as tq=SELECT a, b, (d+e)*2 WHERE c < 100 AND x = 'yes'.

Export textual data: Supply the headers=0 option in case your fields contain textual data, otherwise they might be cut out during export.

这篇关于用于 Google 电子表格 CSV 导出的下载链接 - 带有多张表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆