使用Google电子表格Java API将数据插入Google电子表格
下面是我用来插入数据的代码。它是从谷歌提供的样本中提取的使用Google电子表格Java API将数据插入Google电子表格,java,google-spreadsheet-api,Java,Google Spreadsheet Api,下面是我用来插入数据的代码。它是从谷歌提供的样本中提取的 // Get the spreadsheet feed SpreadsheetFeed feed = client .getFeed( new URL( "https://spreadsheets.google.com/feeds/spreadsheets/private/full
// Get the spreadsheet feed
SpreadsheetFeed feed = client
.getFeed(
new URL(
"https://spreadsheets.google.com/feeds/spreadsheets/private/full"),
SpreadsheetFeed.class);
// Get the worksheet
WorksheetEntry worksheet = feed.getEntries().get(0).getWorksheets()
.get(0);
URL listFeed = worksheet.getListFeedUrl();
ListEntry newEntry = new ListEntry();
String nameValuePairs = "a=b,c=d";
for (String nameValuePair : nameValuePairs.split(",")) {
// Then, split by the equal sign.
String[] parts = nameValuePair.split("=", 2);
String tag = parts[0]; // such as "name"
String value = parts[1]; // such as "Fred"
newEntry.getCustomElements().setValueLocal(tag, value);
}
client.insert(listFeed, newEntry);
我想做的是得到一个工作表并在其中插入一行数据。不管我怎么努力,我都无法使它起作用。每当我在client.insert上运行它时,就会出现以下错误
com.google.gdata.util.InvalidEntryException: Bad Request
我们&39;很抱歉,发生了服务器错误。请稍等,然后尝试重新加载电子表格。我发现电子表格中至少需要有一行,作为插入listentry时发送的标记值的标题和引用。我错过了这个
谢谢。我发现电子表格中至少需要有一行,作为插入listentry时发送的标记值的标题和引用。我错过了这个
谢谢。确保您使用的标记与电子表格中的标题行匹配也很重要,除非它们必须小写并删除所有空格。确保您使用的标记与电子表格中的标题行匹配也很重要,除非它们必须是小写的,并且删除了所有空格。如果这是一个longshot,我很抱歉,但您将如何使用API来做到这一点?@n00b您可以使用基于单元格的提要来更新第一行。如果这是一个longshot,我很抱歉,但是您将如何使用API来做到这一点?@n00b您可以使用基于单元格的提要来更新第一行。