Transfer A Html Table (user Input) To Google Sheets
i want to transfer some user input data from a html page to my google sheet with google´s app scripts. I can do that for single values but could not figure out a nice way to do th
Solution 1:
You can use Sheets API to parse and paste HTML directly.
FrontEnd.html Snippet:
let table = document.getElementById('tbl_posts').outerHTML;
google.script.run.pasteHtml(table);
Code.gs Snippet:
function pasteHtml(table) {
var ss = SpreadsheetApp.getActive();
var req = {
requests: [
{
pasteData: {
html: true,
data: table,
coordinate: {
sheetId: ss.getSheets()[1].getSheetId(), //second sheet!A1
rowIndex: 0,
columnIndex: 0,
},
},
},
],
};
Sheets.Spreadsheets.batchUpdate(req, ss.getId());
}
Post a Comment for "Transfer A Html Table (user Input) To Google Sheets"