简体   繁体   English

通过 Google 表格 api v4 向现有电子表格添加新表格

[英]Adding new sheet to existing spreadsheet via Google sheets api v4

I've been facing an issue within adding a new sheet (tab) to existing spreadsheet.我在向现有电子表格添加新工作表(标签)时遇到了问题。

Before the main issue, I will try to explain why I need to do such a thing and maybe there will be other solution.在主要问题之前,我将尝试解释为什么我需要做这样的事情,也许会有其他解决方案。 I'm trying to upload spreadsheet with several sheets.我正在尝试上传包含多张工作表的电子表格。 When sheets have smaller size, everything is ok.当床单尺寸较小时,一切正常。 But when I do the "service.spreadsheets().create(spreadsheet).execute()" request with really big sheets (like two sheets with 40k cells), I get normal response, but created spreadsheet contains only empty "Untitled document" with empty tab.但是当我使用非常大的工作表(如两张带有 40k 单元格的工作表)执行“service.spreadsheets().create(spreadsheet).execute()”请求时,我得到了正常的响应,但创建的电子表格只包含空的“无标题文档”与空标签。 That's first thing which bothers me, why I don't receive something like "your insert is too big" or something like that.这是困扰我的第一件事,为什么我没有收到诸如“您的插入物太大”之类的消息。

So I would like to create spreadsheet, insert first tab (as a smaller request) and then add another tab (sheet) and so.. But what I only found over the stack and google documentation is "BatchUpdateSpreadsheetRequest".所以我想创建电子表格,插入第一个标签(作为一个较小的请求),然后添加另一个标签(工作表)等等......但我只在堆栈和谷歌文档中找到的是“BatchUpdateSpreadsheetRequest”。 But this request doesn't allow me to add already created sheet, it just create new empty sheet, which is really annoying.但是这个请求不允许我添加已经创建的工作表,它只是创建新的空工作表,这真的很烦人。

Do I miss some API call?我错过了一些 API 调用吗? Also I found over the documentation and stack some limits, but there is no clear info about how big can be requests with sheets (I've seen all the 400k rows, and what you can found here ), but that didn't help a lot.我还发现了文档并堆叠了一些限制,但是没有关于工作表请求有多大的明确信息(我已经看到了所有 400k 行,以及您可以在此处找到的内容),但这并没有帮助很多。

Can someone provide me info how to "split" spreadsheet creation into creating more smaller request so the created spreadsheet will contain all the data?有人可以向我提供如何将电子表格创建“拆分”为创建更小的请求以便创建的电子表格将包含所有数据的信息吗?

Thanks谢谢

The V4 API currently has a limit of 10MB of data per request, though I don't think we advertise this fact in the documentation anywhere right now. V4 API 目前对每个请求的数据限制为 10MB,但我认为我们现在没有在文档中的任何地方宣传这一事实。

To workaround, you can use multiple different requests in a BatchUpdateSpreadsheetRequest -- an AddSheetRequest as you mentioned, plus UpdateCellsRequest , or some number of other requests.要解决此问题,您可以在 BatchUpdateSpreadsheetRequest 中使用多个不同的请求——您提到的 AddSheetRequest ,加上UpdateCellsRequest或一些其他请求。 Check out the guide that details what requests deal with what portions of the spreadsheet.查看详细说明哪些请求处理电子表格的哪些部分的指南

If you have specific portions of the spreadsheet you're curious about how to set, please follow up.如果您对电子表格的特定部分感到好奇如何设置,请跟进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM