FeedURLFactory urlFactory = FeedURLFactory.getDefault();
WorksheetQuery worksheetQuery =
new WorksheetQuery(urlFactory.getWorksheetFeedUrl(ssKey, "private", "values"));
worksheetQuery.setTitleQuery(kind);
WorksheetFeed spreadsheetFeed = ss.query(worksheetQuery, WorksheetFeed.class);
WorksheetEntry workSheet = spreadsheetFeed.getEntries().get(0);
final int colCount = workSheet.getColCount();
String[] columnTitle = new String[colCount];
String[] dataType = new String[colCount];
URL cellFeedUrl = workSheet.getCellFeedUrl();
CellQuery query = new CellQuery(cellFeedUrl);
// Title & Type
query.setMinimumRow(1);
query.setMaximumRow(2);
CellFeed feed = ss.query(query, CellFeed.class);
for (CellEntry cell : feed.getEntries()) {
final String shortId = cell.getId().substring(cell.getId().lastIndexOf('/') + 1);
logger.fine(shortId + ":" + cell.getCell().getValue());
int row = Integer.parseInt(shortId.substring(1, shortId.lastIndexOf('C')));
int col = Integer.parseInt(shortId.substring(shortId.lastIndexOf('C') + 1));
if (row == 1) {
columnTitle[col - 1] = cell.getCell().getValue();
} else {
dataType[col - 1] = cell.getCell().getValue();
}
}
// Data (start from line no.3)
query.setMinimumRow(startIndex);
final int nextMax = startIndex + maxRows - 1;
final int maxRowCount = workSheet.getRowCount();
final int maxRow = (nextMax > maxRowCount) ? maxRowCount : nextMax;
logger.fine(startIndex + "〜" + maxRow);
if (startIndex >= maxRow) {
return null;
}