Googles 웹 사이트 가이드를 참고하십시오. 내 OAuth 키를 올바르게 설정했지만이 셀 추출 코드를 Java에서 작동시키지 못합니다.Google 스프레드 시트 버그
오류 메시지는 다음과 같습니다 스레드에서
예외 "주요"상위를 : 해결되지 않은 컴파일 문제 : 유형 불일치 :
at com.wow.trading.WOWTrading.MySpreadsheetIntegration.main(MySpreadsheetIntegration.java:51)
코드는 정확히 CellEntry에 요소 유형의 SpreadsheetEntry에서 변환 할 수 없습니다 Google 웹 사이트 및 JAR이 누락되지 않았기 때문입니다.
package com.wow.trading.WOWTrading;
import com.google.gdata.client.spreadsheet.*;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.*;
import java.util.*;
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/spreadsheets/private/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 cell feed of the worksheet.
URL cellFeedUrl = worksheet.getCellFeedUrl();
CellFeed cellFeed = service.getFeed(cellFeedUrl, CellFeed.class);
// Iterate through each cell, updating its value if necessary.
// TODO: Update cell values more intelligently.
**for (CellEntry cell : feed.getEntries()) {**
if (cell.getTitle().getPlainText().equals("A1")) {
cell.changeInputValueLocal("200");
cell.update();
} else if (cell.getTitle().getPlainText().equals("B1")) {
cell.changeInputValueLocal("=SUM(A1, 200)");
cell.update();
}
}
}
}
귀하의 질문은 무엇입니까? – SunSparc