首页 \ 问答 \ 如何以编程方式创建带有内容的Google文档电子表格?(How to programmatically create a Google Docs spreadsheet WITH CONTENT?)

如何以编程方式创建带有内容的Google文档电子表格?(How to programmatically create a Google Docs spreadsheet WITH CONTENT?)

我发现了多个有关如何使用Google Spreadsheets API或旧版API创建或编辑Google Doc电子表格的StackOverflow问题。 然而,这个Spreadsheets API似乎是“gdata”库的一部分,我的理解已被弃用。

较新的StackOverflow答案显示了如何使用Drive API创建一个空电子表格,这看起来更加流行。 但是,通过查看该API的文档和示例,它似乎只允许您使用电子表格MIME类型创建新的EMPTY文件。 我还没有找到任何用于创建具有实际内容的电子表格的功能(即行,列,工作表等)。

目前用于创建新的Google Doc电子表格并用内容填充它的过程是什么? Drive API是否具有我不理解的功能? 毕竟,“gdata”库(或至少它的Spreadsheets API部分)是否完全不推荐使用? 有没有第三种方法我完全错过了? 我正在使用Java代码,尽管我确信任何Python API都会有Java等价物。


I have found multiple StackOverflow questions dealing with how to create or edit Google Doc spreadsheets using the Google Spreadsheets API, or older API's. However, this Spreadsheets API seems to be part of the "gdata" library, which to my understanding is deprecated.

Newer StackOverflow answers show how to create an empty spreadsheet using the Drive API, which seems more current. However, from looking at the documentation and examples for that API, it seems to only let you create new EMPTY files with the spreadsheet MIME type. I have not found any functionality for creating a spreadsheet with actual content (i.e. rows, columns, worksheets, etc).

What is the current process for creating a new Google Doc spreadsheet AND populating it with content? Does the Drive API have functionality that I'm not understanding? Is the "gdata" library (or at least its Spreadsheets API portion) not completely deprecated after all? Is there some third approach that I've missed altogether? I'm working with Java code, to the extent that matters, although I'm sure that any Python API would have a Java equivalent.


原文:https://stackoverflow.com/questions/21217995
更新时间:2022-09-19 22:09

最满意答案

即使官方文档给出了CSVREAD('classpath:/org/acme/data/address.csv')例子, Sean Patrick Floyd建议删除主要的斜杠,即:

CREATE TABLE T_FOO (
  ...
) as select * from CSVREAD('classpath:foo.csv');

这是行得通的


Even if the official docs give the CSVREAD('classpath:/org/acme/data/address.csv') example, Sean Patrick Floyd suggested to remove the leading slash, i.e. having:

CREATE TABLE T_FOO (
  ...
) as select * from CSVREAD('classpath:foo.csv');

and this is working!

相关问答

更多
  • 即使官方文档给出了CSVREAD('classpath:/org/acme/data/address.csv')例子, Sean Patrick Floyd建议删除主要的斜杠,即: CREATE TABLE T_FOO ( ... ) as select * from CSVREAD('classpath:foo.csv'); 这是行得通的 ! Even if the official docs give the CSVREAD('classpath:/org/acme/data/address.cs ...
  • 最后我解决了我的问题...... 从1.4.x开始,H2使用MV_STORE(请参阅此处回答和Thomas Mueller评论)。 显然,Web控制台试图自动附加一个.mv.db扩展名。 即使已经有一个带有h2.db扩展名的文件。 所以,我将我的代码的H2版本从1.3.175升级到1.4.178,最后,我可以看到我的数据... 编辑 这是@devdanke提出的另一种解决方案: 您必须手动告诉H2 1.4.x不要使用MV_Store:“; mv_store = false”。 真是麻烦。 例如,您将以类似于 ...
  • 您可以使用RUNSCRIPT SQL语句 : RUNSCRIPT FROM 'test.sql' 或者您可以使用RunScript独立/命令行工具 : java -cp h2*.jar org.h2.tools.RunScript -url jdbc:h2:~/test -script test.sql 您还可以在应用程序中使用RunScript工具: RunScript.execute(conn, new FileReader("test.sql")); You can use the RUNSCR ...
  • 您必须将DatabaseH2插件包含在产品中包含的插件列表中。 由于您使用的是基于特征的产品,因此您应该在功能fpFeature列出它。 在fpFeature打开feature.xml并添加DatabaseH2插件。 You must include the DatabaseH2 plugin in the list of plugins included in the product. Since you are using a feature based product you should list ...
  • 如果你有H2控制台,你可以基本上创建一个新的数据库,无论你想要的。 如果你仔细阅读h2 faq,他们会很好地描述你如何做到这一点。 使用jdbc:h2:〜/ test等数据库URL时,数据库存储在用户目录中。 对于Windows,这通常是C:\ Documents and Settings \或C:\ Users \。 如果未设置基目录(如在jdbc:h2:./ test中),则数据库文件存储在启动应用程序的目录(当前工作目录)中。 从开始菜单使用H2控制台应用程序时,这是/ bin。 基本目录可以在数据库 ...
  • 要检查数据库文件是否存在,您可以使用 if (new java.io.File(databaseFileName).exists()) { ... } 如果文件存在,但数据库已损坏,那么通常您将无法连接到它(尝试连接将抛出异常)。 这是我所知道的最快验证方式。 数据库文件存在的风险很小,但尚未完全初始化。 如果是这种情况,则某些表不存在。 验证所有表存在的标准方法是使用DatabaseMetaData.getTables 。 但是,除非您使用某些危险的功能(例如禁用事务日志或禁用数据库文件锁定),否则数据 ...
  • CSVREAD函数支持带和不带列标题的文件。 如果文件包含列标题,则不要在该函数中提供列列表,例如: SELECT * FROM CSVREAD('test.csv'); SELECT * FROM CSVREAD('data/test.tsv', null, 'rowSeparator=' || CHAR(9)); 如果文件不包含列标题,则在函数调用中提供列列表,例如: SELECT * FROM CSVREAD('test2.csv', 'ID|NAME', 'charset=UTF-8 fieldS ...
  • 假设您在H2和Postgres中使用相同的基础数据运行相同的ANSI兼容查询,您应该得到相同的结果。 在任一数据库中, INNER JOIN的行为都没有什么不同。 但是在代码转储中快速搜索ORDER BY表明您没有在查询中进行任何排序。 我注意到Postgres巧合似乎是在data1列上排序,而H2似乎根本没有排序。 我建议结果集从未排序集的角度来看是相同的。 通常,如果您希望在结果集中进行cetain排序,则需要在生成该数据的查询中使用ORDER BY 。 因此,如果您将ORDER BY data1添加到 ...
  • 要使用其他数据库(例如MySQL),需要在安装服务之前将这些数据库的JDBC驱动程序的位置添加到环境变量H2DRIVERS或CLASSPATH中。 可以设置多个驱动程序; 每个条目需要分开; (Windows)或:(其他操作系统)。 支持路径名中的空格。 不得引用设置。 To use other databases (for example MySQL), the location of the JDBC drivers of those databases need to be added to the ...
  • 您可以直接使用CSV工具,而无需打开数据库 : Csv csv = new Csv(); csv.setOptions("fieldSeparator=,"); String fileName = "/home/testuser/csvfile.csv"; ResultSet rs = csv.read(fileName, null, null); while (rs.next()) { // processing data... } rs.close(); You can use the CSV ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)