Getting a merged cell width on Google Spreadsheet API

后端 未结 2 1314
小蘑菇
小蘑菇 2021-01-15 12:37

I\'m using the Google Spreadsheet API to convert a document containing workers shifts into event calendars. The only problem is that shifts are represented by merged cells a

2条回答
  •  無奈伤痛
    2021-01-15 13:34

    Download from google drive as html, see: Get FontStyle information from Google spreadsheet into appengine

        Drive driveService = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential).build();
        File file = driveService.files().get(this.spreadsheetKey).execute();
        String downloadUrl = file.getExportLinks().get("application/pdf");
        downloadUrl = downloadUrl.replaceFirst("exportFormat=pdf", "exportFormat=html");
        downloadUrl = appendWorksheetGid(downloadUrl); // adds "&gid="+sheetGid
        HttpResponse resp =
                driveService.getRequestFactory().buildGetRequest(new GenericUrl(downloadUrl))
                    .execute();
        System.out.println("downloadUrl:"+downloadUrl);
    
        InputStream fileContent = resp.getContent();
        extractStyleFromHtml(fileContent,downloadUrl);
    

    extractStyleFromHtml uses Jsoup - (Jsoup impressed me)

提交回复
热议问题