“java.lang.String 无法转换为 java.lang.Object”
public class SheetsQuickstart {
private static final String APPLICATION_NAME = "Google Sheets API Java Quickstart";
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
private static final String TOKENS_DIRECTORY_PATH = "tokens";
/**
* Global instance of the scopes required by this quickstart.
* If modifying these scopes, delete your previously saved tokens/ folder.
*/
private static final List<String> SCOPES = Collections.singletonList(SheetsScopes.SPREADSHEETS_READONLY);
private static final String CREDENTIALS_FILE_PATH = "/credentials.json";
/**
* Creates an authorized Credential object.
* @param HTTP_TRANSPORT The network HTTP Transport.
* @return An authorized Credential object.
* @throws IOException If the credentials.json file cannot be found.
*/
public ValueRange getValues(String spreadsheetId, String range, Sheets service) throws IOException {
// [START sheets_get_values]
ValueRange result = service.spreadsheets().values().get(spreadsheetId, range).execute();
int numRows = result.getValues() != null ? result.getValues().size() : 0;
System.out.printf("%d rows retrieved.", numRows);
// [END sheets_get_values]
return result;
}
它抛出错误:(104, 30) java: incompatible types: java.util.List< java.util.List< java.lang.String >> cannot be convert to java.util.List< java.util.List < java .lang.Object>> 我是否错过了创建类?为什么会抛出这个错误。
繁花不似锦
相关分类