I\'ve been using Google Sheets API, and following The Google Guide. However there is no example, even beyond the second page of google, to add a worksheet and write to a new she
I was looking for the Java version of this and I managed to get a working version based on sparky's answer. This should work:
//Set sheet name
//Can be any string, I chose to set it to the account name
String sheetName = mCredential.getSelectedAccountName();
//Create a new AddSheetRequest
AddSheetRequest addSheetRequest = new AddSheetRequest();
SheetProperties sheetProperties = new SheetProperties();
//Add the sheetName to the sheetProperties
addSheetRequest.setProperties(sheetProperties);
addSheetRequest.setProperties(sheetProperties.setTitle(sheetName));
//Create batchUpdateSpreadsheetRequest
BatchUpdateSpreadsheetRequest batchUpdateSpreadsheetRequest = new BatchUpdateSpreadsheetRequest();
//Create requestList and set it on the batchUpdateSpreadsheetRequest
List requestsList = new ArrayList();
batchUpdateSpreadsheetRequest.setRequests(requestsList);
//Create a new request with containing the addSheetRequest and add it to the requestList
Request request = new Request();
request.setAddSheet(addSheetRequest);
requestsList.add(request);
//Add the requestList to the batchUpdateSpreadsheetRequest
batchUpdateSpreadsheetRequest.setRequests(requestsList);
//Call the sheets API to execute the batchUpdate
mService.spreadsheets().batchUpdate(spreadsheetId,batchUpdateSpreadsheetRequest).execute();