Download a Google Docs Spreadsheet as HTML

余生长醉 提交于 2019-11-29 15:49:07

@Andre J's answer works, the code:

                            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);

Just change the exportformat in the exportLink to html.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!