Well, I need to find a way to add a note in a google spreadsheet, I'm using java to connect.
I Have built a request that changes cell colours, but I can't find a way to update cell to add a note.
This is how I change build request to change the colour:
private Request buildRequestToPaintCell(int startRow, int endRow, int startColumn, int endColumn, int sheetId) {
Request request = new Request();
request.setRepeatCell(new RepeatCellRequest()
.setCell(new CellData()
.setUserEnteredFormat(new CellFormat().setBackgroundColor(new Color()
.setRed(1f)
.setGreen(0.0f)
.setBlue(0.0f))))
.setRange(new GridRange()
.setSheetId(sheetId)
.setStartRowIndex(startRow)
.setEndRowIndex(endRow)
.setStartColumnIndex(startColumn)
.setEndColumnIndex(endColumn))
.setFields("userEnteredFormat.backgroundColor")
);
return request;
}
I was expecting this to work, but it doesn't as I set the field as '*' it clears the cell and adds the note, but that's not what I need, I think I'm missing the correct field value to update just the note, I can not find it yet.
private Request buildRequestAddNoteCell(int startRow, int endRow, int startColumn, int endColumn, int sheetId, String note) {
Request request = new Request();
request.setRepeatCell(new RepeatCellRequest()
.setCell(new CellData().setNote(note))
.setRange(new GridRange()
.setSheetId(sheetId)
.setStartRowIndex(startRow)
.setEndRowIndex(endRow)
.setStartColumnIndex(startColumn)
.setEndColumnIndex(endColumn))
.setFields("userEnteredFormat.note")
);
return request;
}
I found it. Had to set the fields as 'note'. It is missing doc about the cell fields.
Example code: