本文整理汇总了Java中com.google.gdata.data.spreadsheet.CellEntry类的典型用法代码示例。如果您正苦于以下问题:Java CellEntry类的具体用法?Java CellEntry怎么用?Java CellEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CellEntry类属于com.google.gdata.data.spreadsheet包,在下文中一共展示了CellEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateWorksheetWithAllItems
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
private void updateWorksheetWithAllItems(WorksheetEntry worksheet, String[] header, List<ReportItem> reportItems, int numberOfRows, int numberOfColumns, String reportSpreadsheetName)
throws BatchInterruptedException, MalformedURLException, IOException, ServiceException
{
URL cellFeedUrl = worksheet.getCellFeedUrl();
CellFeed cellFeed = spreadsheetService.getFeed(cellFeedUrl, CellFeed.class);
Map<String, CellEntry> cellEntries = prepareBatchByQueringWorksheet(cellFeedUrl, numberOfRows, numberOfColumns);
int startingRow = 1;
int rowsInBatch = ((Double) Math.ceil((double)numberOfRows / Properties.googleSheetsBatchUploadSizeSplitFactor.get())).intValue();
int endingRow = rowsInBatch;
for (int i = 0; i < Properties.googleSheetsBatchUploadSizeSplitFactor.get(); i++) {
CellFeed batchRequest = createBatchRequest(header, reportItems, startingRow, endingRow, numberOfColumns, cellEntries);
Link batchLink = cellFeed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
CellFeed batchResponse = spreadsheetService.batch(new URL(batchLink.getHref()), batchRequest);
boolean isSuccess = checkResults(batchResponse);
logger.info((isSuccess ? "Batch operations successful: " : "Batch operations failed: ") + reportSpreadsheetName + " " + worksheet.getTitle().getPlainText() + " starting row: " + startingRow +", through row: " + endingRow);
startingRow = startingRow + rowsInBatch;
endingRow = Math.min(numberOfRows, endingRow + rowsInBatch);
}
}
示例2: createBatchRequest
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
protected CellFeed createBatchRequest(String[] header, List<ReportItem> reportItems, int startingRow, int endingRow, int numberOfColumns, Map<String, CellEntry> cellEntries)
{
CellFeed batchRequest = new CellFeed();
for (int rowIndex = startingRow; rowIndex <= endingRow; rowIndex++) {
for (int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++) {
String id = getR1C1Id(rowIndex, columnIndex);
CellEntry batchEntry = new CellEntry(cellEntries.get(id));
String rowHeader = header[columnIndex - 1];
if (rowIndex == 1) {
batchEntry.changeInputValueLocal(rowHeader);
} else
batchEntry.changeInputValueLocal(reportItems.get(rowIndex - 2).getNamedValues().get(rowHeader));
BatchUtils.setBatchId(batchEntry, id);
BatchUtils.setBatchOperationType(batchEntry, BatchOperationType.UPDATE);
batchRequest.getEntries().add(batchEntry);
}
}
return batchRequest;
}
示例3: prepareBatchByQueringWorksheet
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
private Map<String, CellEntry> prepareBatchByQueringWorksheet(URL cellFeedUrl, int numberOfRows, int numberOfColumns) throws IOException, ServiceException
{
CellFeed batchRequest = new CellFeed();
for (int rowIndex = 1; rowIndex <= numberOfRows; rowIndex++) {
for (int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++) {
String id = getR1C1Id(rowIndex, columnIndex);
CellEntry batchEntry = new CellEntry(rowIndex, columnIndex, id);
batchEntry.setId(String.format("%s/%s", cellFeedUrl.toString(), id));
BatchUtils.setBatchId(batchEntry, id);
BatchUtils.setBatchOperationType(batchEntry, BatchOperationType.QUERY);
batchRequest.getEntries().add(batchEntry);
}
}
CellFeed cellFeed = spreadsheetService.getFeed(cellFeedUrl, CellFeed.class);
CellFeed queryBatchResponse = spreadsheetService.batch(new URL(cellFeed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM).getHref()), batchRequest);
Map<String, CellEntry> cellEntryMap = new HashMap<String, CellEntry>(numberOfColumns);
for (CellEntry entry : queryBatchResponse.getEntries()) {
cellEntryMap.put(BatchUtils.getBatchId(entry), entry);
}
return cellEntryMap;
}
示例4: getTitlesWithQueries
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
private Map<Integer, TitleWithQueries> getTitlesWithQueries(List<CellEntry> cellEntries, Map<String, String> header, String worksheetId)
{
Map<Integer, TitleWithQueries> returnValue = Maps.newLinkedHashMap();
for (CellEntry cell : cellEntries) {
String column = getColumnFromCellAddress(cell);
Integer row = getRowFromCellAddress(cell);
String value = cell.getCell().getValue().trim();
if (row == 1)
continue;
TitleWithQueries titleWithQueries = returnValue.get(row);
if (titleWithQueries == null)
titleWithQueries = new TitleWithQueries(worksheetId);
String headerValue = header.get(column);
titleWithQueries.setValue(headerValue, value);
returnValue.put(row, titleWithQueries);
}
return returnValue;
}
示例5: getColumnHeaders
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
/**
* Retrieves the columns headers from the cell feed of the worksheet
* entry.
*
* @param worksheet worksheet entry containing the cell feed in question
* @return a list of column headers
* @throws Exception if error in retrieving the spreadsheet information
*/
public List<String> getColumnHeaders(WorksheetEntry worksheet)
throws Exception {
List<String> headers = new ArrayList<String>();
// Get the appropriate URL for a cell feed
URL cellFeedUrl = worksheet.getCellFeedUrl();
// Create a query for the top row of cells only (1-based)
CellQuery cellQuery = new CellQuery(cellFeedUrl);
cellQuery.setMaximumRow(1);
// Get the cell feed matching the query
CellFeed topRowCellFeed = service.query(cellQuery, CellFeed.class);
// Get the cell entries fromt he feed
List<CellEntry> cellEntries = topRowCellFeed.getEntries();
for (CellEntry entry : cellEntries) {
// Get the cell element from the entry
Cell cell = entry.getCell();
headers.add(cell.getValue());
}
return headers;
}
示例6: refresh
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
/**
* Load all the cells from Google Spreadsheets.
*/
public synchronized void refresh() {
cells.clear();
CellFeed cellFeed = getCellFeed();
if (cellFeed != null) {
for (CellEntry entry : cellFeed.getEntries()) {
doAddCell(entry);
}
}
int oldMaxRow = maxRow;
int oldMaxCol = maxCol;
maxRow = cellFeed.getRowCount();
maxCol = cellFeed.getColCount();
fireTableDataChanged();
if (maxRow != oldMaxRow || maxCol != oldMaxCol) {
fireTableStructureChanged();
}
}
示例7: setValueAt
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
/**
* Implements the Swing method for handling cell edits.
*/
public void setValueAt(Object value, int screenRow, int screenCol) {
int row = screenRow + 1; // account for the fact Swing is 0-indexed
int col = screenCol + 1;
// Pop up a little window to indicate that this is busy.
JFrame statusIndicatorFrame = new JFrame();
statusIndicatorFrame.getContentPane().add(new JButton("Updating..."));
statusIndicatorFrame.setVisible(true);
statusIndicatorFrame.setSize(200, 100);
CellEntry entry = actuallySetCell(row, col, value.toString());
if (entry != null) {
doAddCell(entry);
}
statusIndicatorFrame.dispose();
fireTableDataChanged();
}
示例8: getCellEntryMap
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
private Map<String, CellEntry> getCellEntryMap(List<SpreadsheetCell> cells) throws
IOException, ServiceException {
CellFeed batchRequest = new CellFeed();
for (SpreadsheetCell cell : cells) {
CellEntry batchEntry = new CellEntry(cell.row, cell.col, cell.id);
batchEntry.setId(String.format("%s/%s", data.cellFeedURL.toString(), cell.id));
BatchUtils.setBatchId(batchEntry, cell.id);
BatchUtils.setBatchOperationType(batchEntry, BatchOperationType.QUERY);
batchRequest.getEntries().add(batchEntry);
}
CellFeed batchResponse = batchRequest(data.cellBatchURL, batchRequest);
Map<String, CellEntry> cellEntryMap = new HashMap<String, CellEntry>(cells.size());
for (CellEntry entry : batchResponse.getEntries()) {
cellEntryMap.put(BatchUtils.getBatchId(entry), entry);
}
return cellEntryMap;
}
示例9: getNextCellRow
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
public CellEntry[] getNextCellRow(boolean acceptEmptyLines)
{
if (this.currentRow < this.rows)
{
CellEntry[] entry = this.cellEntries[this.currentRow++];
if (!acceptEmptyLines)
{
while (entry != null && isEmptyRow(entry))
{
entry = getNextCellRow(acceptEmptyLines);
}
}
return entry;
} else
{
return null;
}
}
示例10: retrieveData
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
public GSpreadResultSet retrieveData() throws Exception {
URL worksheetUrl = this.getConfig().generateWorksheetFeedURL();
WorksheetFeed feedw = this.getConfig().getFeed(worksheetUrl, WorksheetFeed.class);
WorksheetEntry worksheetEntry = feedw.getEntries().get(this.getWorksheetNumber() - 1);
CellFeed feedc = this.getConfig().getFeed(worksheetEntry.getCellFeedUrl(), CellFeed.class);
List<CellEntry> entries = feedc.getEntries();
GSpreadResultSet grs = new GSpreadResultSet();
/* store the data */
for (CellEntry entry : entries) {
grs.addCell(this.getPosStringFromId(entry.getId()),
entry.getTextContent().getContent().getPlainText());
}
return grs;
}
示例11: getGSpreadHeaders
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
private static ColumnInfo[] getGSpreadHeaders(Connection connection,
String sheetName) throws SQLException {
WorksheetEntry currentWorksheet;
List<ColumnInfo> columns = new ArrayList<ColumnInfo>();
if (!(connection instanceof TGSpreadConnection)) {
throw new SQLException("Invalid connection type");
}
currentWorksheet = getCurrentWorkSheetEntry((TGSpreadConnection) connection, sheetName);
if (currentWorksheet == null) {
throw new SQLException("Worksheet '" + sheetName + "' does not exist");
}
CellFeed cellFeed = getGSpreadCellFeed((TGSpreadConnection) connection, currentWorksheet);
for (CellEntry cell : cellFeed.getEntries()) {
if (!getCellPosition(cell.getId()).startsWith("R1")) {
break;
}
ColumnInfo column =
new ColumnInfo(cell.getTextContent().getContent().getPlainText());
column.setTableName(sheetName);
column.setSqlType(cell.getContent().getType());
column.setId(getColumnIndex(cell.getId()) - 1);
columns.add(column);
}
return columns.toArray(new ColumnInfo[columns.size()]);
}
示例12: extractTitlesWithQueries
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
public Map<Integer, TitleWithQueries> extractTitlesWithQueries(String worksheetId) throws Throwable, IOException, ServiceException
{
Map<Integer, TitleWithQueries> titlesWithQueries = null;
SpreadsheetEntry spreadsheet = getSpreadsheet(Properties.inputQueriesSheet.get());
WorksheetEntry worksheet = getWorksheet(spreadsheet, worksheetId);
if (worksheet != null) {
List<CellEntry> cellEntries = getCellsForWorksheet(worksheet).getEntries();
Map<String, String> header = getHeader(cellEntries);
titlesWithQueries = getTitlesWithQueries(cellEntries, header, worksheetId);
}
return titlesWithQueries;
}
示例13: extractReport
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
public void extractReport(Report report, boolean isDetailReport) throws Throwable
{
List<ReportItem> reportItems = null;
String spreadsheetName = getReportName(isDetailReport);
SpreadsheetEntry spreadsheet = getSpreadsheet(spreadsheetName);
String worksheetId = getLatestWorksheetId(spreadsheet);
WorksheetEntry worksheet = getWorksheet(spreadsheet, worksheetId);
if (worksheet != null) {
List<CellEntry> cellEntries = getCellsForWorksheet(worksheet).getEntries();
Map<String, String> header = getHeader(cellEntries);
reportItems = getReport(cellEntries, header, isDetailReport);
}
report.setItems(reportItems);
report.setDate(worksheetId);
}
示例14: checkResults
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
protected boolean checkResults(CellFeed batchResponse)
{
boolean isSuccess = true;
for (CellEntry entry : batchResponse.getEntries()) {
String batchId = BatchUtils.getBatchId(entry);
if (!BatchUtils.isSuccess(entry)) {
isSuccess = false;
BatchStatus status = BatchUtils.getBatchStatus(entry);
logger.error(String.format("%s failed (%s) %s", batchId, status.getReason(), status.getContent()));
}
}
return isSuccess;
}
示例15: getHeader
import com.google.gdata.data.spreadsheet.CellEntry; //导入依赖的package包/类
private Map<String, String> getHeader(List<CellEntry> cellEntries)
{
Map<String, String> returnValue = Maps.newLinkedHashMap();
for (CellEntry cell : cellEntries) {
String column = getColumnFromCellAddress(cell);
Integer row = getRowFromCellAddress(cell);
String value = cell.getCell().getValue();
if (row == 1)
returnValue.put(column, value);
}
return returnValue;
}