WorksheetEntry 类型未定义方法 setColCount(int)

The method setColCount(int) is undefined for the type WorksheetEntry

我想在 Android 中集成 Google 驱动器(创建文件夹和电子表格)和 Sheets API(填充电子表格)而不使用客户管理器验证。因此,我对电子表格使用 Drive API v2 Client Library for Java for drive integration and Sheets API。我已成功实施 OAuth2.0 身份验证和驱动器集成(创建文件夹和电子表格),但是由于“x 方法未定义 y”类型的错误,我无法使用 Sheet API。

我授权SheetAPI服务如下:

SpreadsheetService service = new SpreadsheetService("Aplication-name");
service.setAuthSubToken(credential.getAccessToken());

我能够打印 spreadsheets.However 的列表,当我尝试使用 setColCount(int) 和 setRowCount(int) 编辑工作表尺寸时,它显示以下错误:

The method setColCount(int) is undefined for the type WorksheetEntry

The method setRowCount(int) is undefined for the type WorksheetEntry

但是根据 Sheets API Documentation,这些方法应该按如下方式工作:

    // Get the first worksheet of the first spreadsheet.
    // TODO: Choose a worksheet more intelligently based on your
    // app's needs.
    WorksheetFeed worksheetFeed = service.getFeed(
        spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
    List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
    WorksheetEntry worksheet = worksheets.get(0);

    // Update the local representation of the worksheet.
    worksheet.setTitle(new PlainTextConstruct("Updated Worksheet"));
    worksheet.setColCount(5);
    worksheet.setRowCount(15);

    // Send the local representation of the worksheet to the API for
    // modification.
    worksheet.update();

我可以使用 worksheet.getColCount() 和 worksheet.getRowCount() 方法,但设置方法不起作用。

我已经按照给定的说明导入了以下用于驱动器集成的 JAR here

google-api-client-1.20.0.jar

google-oauth-client-1.20.0.jar

google-http-client-1.20.0.jar

jsr305-1.3.9.jar

google-http-client-jackson2-1.20.0.jar

jackson-core-.1.3.jar

google-api-client-android-1.20.0.jar (for SDK >= 2.1)

google-http-client-android-1.20.0.jar

和以下 JAR 的 Sheets 集成指令给定 here:

gdata-appsforyourdomain-1.0

gdata-base-1.0

gdata-calendar-1.0

gdata-client-1.0

gdata-codesearch-1.0

gdata-photos-1.0

gdata-spreadsheet-1.0

guava-11.0.2

jsr305

javax.mail

会不会是因为导入的 JAR 之间存在某种冲突? 任何帮助表示赞赏。提前致谢!

经过几天的挫折,我终于注意到官方表格 API 文档中的下载 link 有过时的电子表格 api jar (gdata-spreadsheet-1.0.jar 而不是 gdata-spreadsheet-3.0.jar)。您可以从 this link. (Extract zip and go to java\libs folder). Refer to 下载 gdata-spreadsheet-3.0.jar SO post 以获取要导入的 jar 文件列表。