How to send data to Google Sheets?
- Install Google Backup and Sync tool
- Create a new folder on your hard drive to be synced to Google Drive
- Run Google Backup and Sync tool and choose the folder
- In Scoreboard OCR choose “CSV File” output and save the file to that folder
- In Google Drive check the content of the .csv file and see if it updates as digits on scoreboard change
- In Google Drive make the .csv file publicly availale using Sharing
- Copy link to the .csv file in Google Drive. It will look like this (url1):
https://drive.google.com/file/d/[FILE_ID]/view?usp=sharing
- Copy it to notepad and change to ulr2:
http://drive.google.com/uc?export=view&id=[FILE_ID]
- Create a Google Sheet
- Choose a cell where to display scoreboard data and paste the following formula using url2:
=IMPORTDATA("http://drive.google.com/uc?export=view&id=[FILE_ID]")
- Go to Tools → Script Editor
- Copy paste the following lines:
function forceRefreshSheetFormulas(sheetName) { var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet(); var sheet = activeSpreadsheet.getSheetByName("Lapa1"); var range = sheet.getDataRange(); var numCols = range.getNumColumns(); var numRows = range.getNumRows(); var rowOffset = range.getRow(); var colOffset = range.getColumn(); // Change formulas then change them back to refresh it var originalFormulas = range.getFormulas(); //Loop through each column and each row in the sheet //`row` and `col` are relative to the range, not the sheet for (row = 0; row < numRows ; row++){ for(col = 0; col < numCols; col++){ if (originalFormulas[row][col] != "") { range.getCell(row+rowOffset, col+colOffset).setFormula(""); } }; }; SpreadsheetApp.flush(); for (row = 0; row < numRows ; row++){ for(col = 0; col < numCols; col++){ if (originalFormulas[row][col] != "") { range.getCell(row+rowOffset, col+colOffset).setFormula(originalFormulas[row][col]); } }; }; SpreadsheetApp.flush(); };
- Save the script and give it a name
- Run the script and see if there are no errors
- Set up a trigger for the scirpt to run 'Time-driven' and 'Every-minute'
Here is a helpful tutorial for setting up script on Google Sheets
Total delay is 30sec - 1,5min