有这样的错误:在线程ClassCastException异常谷歌电子表格
异常“主要” java.lang.ClassCastException:com.google.gdata.data.TextContent不能转换为com.google.gdata。 data.OutOfLineContent
这是该行的代码错误:URL listFeedUrl = worksheet.getListFeedUrl();
我想检索基于列表的饲料,但是有这样的错误!
帮帮我。请!!!
我的课是:
package it.unical.mat.google_data;
import android.support.multidex.MultiDex;
import com.google.gdata.client.authn.oauth.*;
import com.google.gdata.client.spreadsheet.*;
import com.google.gdata.data.*;
import com.google.gdata.data.batch.*;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.*;
import java.util.*;
import java.util.jar.Attributes;
public class MySpreadsheetIntegration {
public static void main(String[] args)
throws AuthenticationException, MalformedURLException, IOException, ServiceException{
SpreadsheetService service =
new SpreadsheetService("MySpreadsheetIntegration-v1");
// TODO: Authorize the service object for a specific user (see other sections)
// Define the URL to request. This should never change.
URL SPREADSHEET_FEED_URL = new URL(
"https://spreadsheets.google.com/feeds/worksheets/api-key-here/public/full");
// Make a request to the API and get all spreadsheets.
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL,
SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
if (spreadsheets.size() == 0) {
// TODO: There were no spreadsheets, act accordingly.
}
// TODO: Choose a spreadsheet more intelligently based on your
// app's needs.
SpreadsheetEntry spreadsheet = spreadsheets.get(0);
System.out.println(spreadsheet.getTitle().getPlainText());
// 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);
// Fetch the list feed of the worksheet.
URL listFeedUrl = worksheet.getListFeedUrl();
ListFeed listFeed = service.getFeed(listFeedUrl, ListFeed.class);
// Iterate through each row, printing its cell values.
for (ListEntry row : listFeed.getEntries()) {
// Print the first column's cell value
System.out.print(row.getTitle().getPlainText() + "\t");
// Iterate over the remaining columns, and print each cell value
for (String tag : row.getCustomElements().getTags()) {
System.out.print(row.getCustomElements().getValue(tag) + "\t");
}
System.out.println();
}
System.out.println("ok!");
}
}
如果我使用您的URL tipe有此错误:线程“main”com.google.gdata.util.InvalidEntryException中的异常:错误请求 VALUE divisibilitàsconosciuto。为什么? –
你用钥匙取代了“abc”吗? – Friwi
当然,我的电子表格是公开的! –