Posts

Showing posts from September, 2021

Find Product Prices in Google Sheets with Vlookup and Match Functions

Image
You run a coffee shop and you are looking for a spreadsheet formula to quickly look up prices of the product that your customer has ordered. You have the price matrix stored in a Google Sheet with the names of beverages in one column and the quantity-wise prices in the adjacent columns. When a customer selects their favorite beverage and the cup size, you can use the MATCH function to find the relative position of the column and row in the price table that matches the selected beverage and quantity. Next, use the INDEX function to find the actual price of the beverage in the selected quantity. In our Starbuck Coffee example, the coffee prices are stored in the range B2:B11. The customer’s beverage name (Caffè Mocha in this example) is stored in the cell G3. The following MATCH function will return the relative position of the selected beverage from the list of beverages. =MATCH(G3, $B$2:$B$11, 0) The third parameter of the MATCH function is set to 0 since we want the exact ma...

Improve Performance of Google Apps Script with Memoization

A folder in Google Drive contains a bunch of CSV files and you are required to write a Google Script to find a particular value in the CSV files. The solution is simple: Use the Drive API to get a list of CSV files in the specified folder. Parse the CSV files one by one using the Utilities.parseCsv() function. Read the CSV file, line by line, until the value is found and return the line number. const findContentInCSVFiles = ( folderId , searchString ) => { const folder = DriveApp . getFolderById ( folderId ) ; const files = folder . getFilesByType ( "text/csv" ) ; while ( files . hasNext ( ) ) { const file = files . next ( ) ; const fileContent = file . getBlob ( ) . getDataAsString ( ) ; const linesOfData = Utilities . parseCsv ( fileContent , "," ) ; let found = false ; let lineNumber = 0 ; for ( ; lineNumber < linesOfData . length && ! found ; lineNumber += 1 ) { ...

How to Request Payments with Stripe Checkout and Google Sheets

Image
Stripe payment links make it easy for you to accept credit card payments from customers anywhere in the world without even having a website. You can use the Stripe dashboard to generate payment links and then send the links over email, WhatsApp, SMS, or share them on your social media pages. A limitation of Stripe Payment links is that you can only generate them manually. Stripe has a feature-rich API but it doesn’t allow you to generate payment links automatically. Stripe Payment Link Generator If you are looking to generate custom payment links for Stripe in bulk and send them to your customers, you can consider using Stripe Checkout. These are payment forms hosted on the Stripe website and allow you to collect only payments your customers. It is important to note that Stripe Checkout sessions will automatically expire after 24 hours. As an alternative, you can use the Stripe API to generate invoices and email the invoice link to your customers. Generate Stripe Checkout L...

How to Request Payments with Stripe Checkout and Google Sheets

Image
Stripe payment links make it easy for you to accept credit card payments from customers anywhere in the world without even having a website. You can use the Stripe dashboard to generate payment links and then send the links over email, WhatsApp, SMS, or share them on your social media pages. A limitation of Stripe Payment links is that you can only generate them manually. Stripe has a feature-rich API but it doesn’t allow you to generate payment links automatically. Stripe Payment Link Generator If you are looking to generate custom payment links for Stripe in bulk and send them to your customers, you can consider using Stripe Checkout. These are payment forms hosted on the Stripe website and allow you to collect only payments your customers. It is important to note that Stripe Checkout sessions will automatically expire after 24 hours. As an alternative, you can use the Stripe API to generate invoices and email the invoice link to your customers. Generate Stripe Checkout L...

How to Delete Blank Rows from Tables in your Google Documents

Image
The Document Studio add-on helps you generate Google Documents from data in Google Sheets and Google Form responses. You can create a template in Google Docs and the add-on will replace the placeholders with answers submitted in the Google Form response . This approach may however create a lot of blank rows in the table for answers that have no response in Google Forms. To give you an example, if the user has not answered the Age question, the generated document will have a row for the question but with a blank value. Remove Blank Rows in Google Docs With the help of Google Apps Script, we can easily pull all tables that are contained in the body of a Google Document, iterate through each row in the table and, if there’s no value in the row, we can safely remove the row from the table. Inside your Google Document, go to the Tools menu, choose Script Editor and paste the following code. Go to the Run menu and choose RemoveBlankRows from the dropdown to run the script. const ...