Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google drive api 以HTML格式下载谷歌文档电子表格_Google Drive Api_Google Docs Api - Fatal编程技术网

Google drive api 以HTML格式下载谷歌文档电子表格

Google drive api 以HTML格式下载谷歌文档电子表格,google-drive-api,google-docs-api,Google Drive Api,Google Docs Api,我正在使用GoogleDriveAPI和php来做各种奇妙的事情,但是我一直在下载HTML格式的电子表格。我可以使用getExportLinks()方法以各种格式下载它,但我只需要工作表中的文本,而不是docx或ods中的格式化文件 通过使用/feeds/download/spreadsheets/Export?exportFormat=html&format=html&key=ID url,google docs api可以实现这一点。但是当我使用它的时候,它现在被重定向了 是否可以使用驱动器

我正在使用GoogleDriveAPI和php来做各种奇妙的事情,但是我一直在下载HTML格式的电子表格。我可以使用getExportLinks()方法以各种格式下载它,但我只需要工作表中的文本,而不是docx或ods中的格式化文件

通过使用/feeds/download/spreadsheets/Export?exportFormat=html&format=html&key=ID url,google docs api可以实现这一点。但是当我使用它的时候,它现在被重定向了


是否可以使用驱动器api将电子表格下载为html格式?

只需将exportLink中的exportformat更改为html即可。

@Andre J的答案有效,代码:

                            Drive driveService = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential).build();
                            File file = driveService.files().get(____documentKey____).execute();
                            String downloadUrl = file.getExportLinks().get("application/pdf");
                            downloadUrl = downloadUrl.replaceFirst("exportFormat=pdf", "exportFormat=html");
                            HttpResponse resp =
                                    driveService.getRequestFactory().buildGetRequest(new GenericUrl(downloadUrl))
                                        .execute();
                            System.out.println("downloadUrl:"+downloadUrl);
                            InputStream fileContent = resp.getContent();
                            String htmlContent = new Scanner(fileContent).useDelimiter("\\A").next();
                            System.out.println("htmlContent:"+htmlContent);

你找到解决这个问题的办法了吗?电子表格可以导出到xlsx、ods和pdf,但不能导出到HTML!