If I create a Google document with a checklist, how do I tell whether an item is checked or unchecked? When I diff the document json, it is the same in either state (except for revision number).
Starting with a blank document, sample code to create a checkbox:
List<Request> requests = new ArrayList<>();
//Checkbox
requests.add(new Request().setInsertText(new InsertTextRequest()
.setText("\n\n")
.setLocation(new Location().setIndex(1))));
requests.add(new Request().setInsertText(new InsertTextRequest()
.setText("MARK\n")
.setLocation(new Location().setIndex(2))));
requests.add(new Request().setCreateParagraphBullets(
new CreateParagraphBulletsRequest()
.setRange(new Range()
.setStartIndex(2)
.setEndIndex(3))
.setBulletPreset("BULLET_CHECKBOX")));
BatchUpdateDocumentRequest batchUpdateDocumentRequest = new BatchUpdateDocumentRequest();
BatchUpdateDocumentResponse response = service.documents().batchUpdate(documentId, batchUpdateDocumentRequest.setRequests(requests)).execute();
`
I can click or unclick the checkbox, but the document remains unchanged when I look at it via:
Document document = service.documents().get(documentId).execute(); l.info(document.toPrettyString());
Anyone have experience with this?
Aucun commentaire:
Enregistrer un commentaire