How to insert data cells to a google spreadsheet using Google gdata-client API

China☆狼群 提交于 2019-12-11 06:27:52

问题


I've got a requirement to populate a google spreadsheet with some records using JAVA. For this, I've used Google gdata client APIs to connect to the appropriate google spreadsheet and query data. However, although I managed to retrieve the data from the spreadsheet, I'm still struggling to find a way to insert some data cells to the google spreadsheet programmatically. I've tried a several methods and samples with no success. Appreciate if somebody who is much familiar with the gdata client APIs could shed some light on this.

Shown below is one method that I've tried upon inserting data to the spreadsheet without any luck.

SpreadsheetService service = getSpreadSheetService();
WorksheetEntry currentWorkSheet = getCurrentWorkSheetEntry();

ListFeed listFeed = getListFeed(service, currentWorkSheet);
ListEntry row = listFeed.createEntry();
row.getCustomElements().setValueLocal("ID", "1");
row.getCustomElements().setValueLocal("NAME", "Prabath");

service.insert(currentWorkSheet.getListFeedUrl(), row);

The aforementioned code snippet throws the following errors.

Caused by: com.google.gdata.util.NotImplementedException: Not Implemented
Bad or unsupported projection for this type of operation.

    at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:617)
    at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
    at com.google.gdata.client.Service.insert(Service.java:1409)
    at com.google.gdata.client.GoogleService.insert(GoogleService.java:613)

Appreciate any help on this.

Thanks in advance, Prabath

来源:https://stackoverflow.com/questions/11958321/how-to-insert-data-cells-to-a-google-spreadsheet-using-google-gdata-client-api

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