public com.google.gdata.data.docs.SpreadsheetEntry createSpreadsheet( String _title, DocumentListEntry _destinationFolderEntry, String _defaultWorksheetName, int _rows, int _columns) throws IOException, ServiceException { com.google.gdata.data.docs.SpreadsheetEntry newEntry = new com.google.gdata.data.docs.SpreadsheetEntry(); newEntry.setTitle(new PlainTextConstruct(_title)); String destFolder = ((MediaContent) _destinationFolderEntry.getContent()).getUri(); URL destinationURL = new URL(destFolder); com.google.gdata.data.docs.SpreadsheetEntry newSpreadsheetEntry = docsService.insert(destinationURL, newEntry); // convert from Docs API Spreadsheet to Spreadsheet API Spreadsheet WorksheetEntry worksheet = getSpreadsheetEntryFromDocumentListEntry(newSpreadsheetEntry).getDefaultWorksheet(); worksheet.setTitle(new PlainTextConstruct(_defaultWorksheetName)); worksheet.setRowCount(_rows); worksheet.setColCount(_columns); worksheet.update(); return newSpreadsheetEntry; }
public WorksheetEntry createWorksheet(URL url, String worksheetTitle, int rows, int columns) throws IOException, ServiceException { WorksheetEntry worksheet = new WorksheetEntry(); worksheet.setTitle(new PlainTextConstruct(worksheetTitle)); worksheet.setRowCount(rows); worksheet.setColCount(columns); return spreadsheetService.insert(url, worksheet); }
public URL createWorksheet( URL url, String worksheetTitle, int rows, int columns, List<String> columnNames) throws IOException, ServiceException { WorksheetEntry worksheet = new WorksheetEntry(); worksheet.setTitle(new PlainTextConstruct(worksheetTitle)); worksheet.setRowCount(rows); worksheet.setColCount(columns); WorksheetEntry createdWorksheet = spreadsheetService.insert(url, worksheet); // create header CellFeed cellFeed = spreadsheetService.getFeed(createdWorksheet.getCellFeedUrl(), CellFeed.class); int i = 1; for (String columnName : columnNames) { CellEntry cellEntry = new CellEntry(1, i, columnName); cellFeed.insert(cellEntry); i++; } return createdWorksheet.getListFeedUrl(); }