I am writing to you because I am looking for information and I can't find anything on the subject.
I would like to transfer the information in a google Docs directly into a google Sheets. I know that the reverse is possible but I do not know if it is possible in this sense.
If you have any information on the subject, I am interested.
Thanks in advance for your answers (sorry for my english, i'm french and i don't speak very good this language).
CodePudding user response:
Sample Solution:
This is just a basic sample solution of passing a paragraph/sentence to a variable and setting its value to a specified cell on Google Sheets.
function myFunction() {
var body = DocumentApp.getActiveDocument().getBody();
var text = body.findText('Lorem');
var el1 = text.getElement();
var settxt = el1.asText().getText();
var ss = SpreadsheetApp.openById('SHEETID');
var sheet = ss.getSheetByName('Sheet1');
sheet.getRange('A1').setValue(settxt);
Logger.log(settxt);
}
There are various ways on how we can achieve this which heavily depends on the formatting of the data on Google Docs. So I'd recommend reading through these documentations on both Google Docs and Google Sheets using Google Apps Script to be familiarized with various functions/methods you can use to manipulate certain formatting within both services.
References:
Gets the sentence or paragraph that starts with Lorem, and paste it into Cell A1