How to extrapolate data from QR Codes
QR codes are a convenient way to store all kinds of data in a small space and are easy to generate and use.
A single QR code may encode different pieces of information that can be inserted in other programs such as an excel spreadsheet, inventory software, etc.
But to insert the data contained in a single QR Code in different fields of a program, it’s required an additional step.
For example, you may have a QR Code which contains more information in different lines, like this:
Mr John Smith
132, My Street,
Kingston, New York 12401
United States
and the corresponding QR Code is:
if you want to extract the data from the QR Code into the cells of a spreadsheet, like this:
you’ll need to split the initial string using as separator the \n
character.
To do that follow this procedure:
- Open Barcode to PC server on your computer
- Click the settings icon (up-right side)
- Click the component that is in the Output template field and enable the Skip output option
- Drag & drop the components from the Available components field to the Output template field a component and a component
- Click on the component that you just added and edit the JavaScript field to read:
barcode.split('\n')[0]
- Repeat the previous step and increase the number on the square braket to capture the various pieces of information, eg.
barcode.split('\n')[1]
.
as shown here:
This way the BARCODE component will take care of acquiring a barcode and store its value in the barcode variable.
The JAVASCRIPT FUNCTION, instead, will read the data stored in the barcode variable, split the string into multiple pieces, and return the n-th piece specified by the number in the square brackets.
Or, alternatively, you can import the .btpt file (Output template file) of this example and then edit it to fit your needs:
Get the download link for these files:
- QR Code address example.btpt
- spreadsheet.xlsx
After that your Output Template is set up you can save the server settings, position the cursor of your computer in your software where you want the data to be typed in, and scan from the app.