Is there a simple script one could you to scan QR code data and directly enter data the information into a specific column of the Google spreadsheet?

落花浮王杯 提交于 2021-01-28 06:40:32

问题


Lets see we have a simple spreadsheet that looks like this: TimeStamp, Name, Age, Email, QR code, Scanned Info Row1
Row2 Row3

Then column "QR code" is generated by using the trick from here https://docs.google.com/spreadsheets/d/1hBMoc-FmAXf4z3LOGez8hnXg_S6rbCnCDVNzfQOhlPc/template/preview?usp=drive_web and the QR code simply encodes the Name info per row which represents 3 different people in this case.

Now, If one were to scan these 3 QR codes, how could I extract the information of the QR codes (names in this case) and enter it under the scanned info column? As a sanity check, Scanned Info column should be identical to the Name column but scanned info is directly filled via QR code scans while for the sake or argument, other columns were manually entered.

Would be nice to be able to use a regular android phone to scan the QR code (i.e. not bound any special apps) and get the data embedded in the form (in a specific column here- Scanned Info column). This spreadsheet is a Google Spreadsheet i.e., an online document and should be updated as and when the QR codes are scanned.

Additional challenge being, how do we select which row of the Scanned Info columns to place the information so that the column remains in the same order as the Name column (which is not arranged alphabetically).


回答1:


QR codes are just a type of machine-readable barcode containing information, and by using one alone it isn't possible to run a script or program.

Most QR readers will automatically open a web browser when a QR code containing a URL is scanned, which is the extent you're really able to do though. You can use this to your advantage to build a workaround to grap the data you're looking for.

You can set up a php server-side script which can take ? parameters in URLs for the cell or cell range you want to be able to read. The script should be designed to take in a range in A1 notation (for example www.someexampledomain.com/page.php?range=a1). Taking this range, you can follow the PHP Quickstart tutorial to connect to the Google Sheets API and fetch values of cells or ranges of cells based on the ? parameters you passed in the URL. For example if you passed something like ?range=a1 in the URL you could take the parameter and call

$response = $service->spreadsheets_values->get($spreadsheetId, $range);

Where $range is the range passed via URL. You can find the reference for Google spreadsheets here, and the value for setting and gettinv cell values here.

The PHP page can then generate HTML content which is returned as the response to the request which will be viewed in the browser that is opened by the URL in the QR code. Each QR code will have to be generated to have the cell range in the URL so that the PHP script can fetch the relevant information.

This is just a simple step-by-step guide for a way to achieve this, but this is just one of a few ways you could potentially achieve this.



来源:https://stackoverflow.com/questions/57085364/is-there-a-simple-script-one-could-you-to-scan-qr-code-data-and-directly-enter-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!