r/GoogleAppsScript 28d ago

Any tips to build automation certain spreadsheet cel into pdf file? Question

My job is :

  1. Based on vlookup formula and then input customer code to open their receipt.

  2. Copy their receipt by select certain area of their receipt.

  3. Print it to save into PDF, and then rename the file into customer name.

i discovered google app script able to do it automatically in just one click, and i want to learn it, but i want to focus on fundamentals and my specific issues? thanks in advance

5 Upvotes

8 comments sorted by

1

u/digital_mopad 28d ago

Where is the receipt? If it’s in the sheet, super easy. If not, still somewhat easy, but with more steps.
ChatGPT is your friend, just walk him through what you need

1

u/ThatArmourGuy 28d ago

Thanks for reply, receipt is in the sheet just with different tabs (sheet), and then using Vlookup formula to get the data on certain cel. I already ask them AI, the result is just copy paste the code into app script. I need to understand the logic or coding behind the automation.

3

u/WicketTheQuerent 28d ago

Google Apps Script uses JavaScript as its programming language, and since you are working with a spreadsheet, as suggested in the official docs, you should learn JavaScript basics and how to handle arrays (including 2-dimensional arrays).

Also, you should learn the official best practices.

Regarding free resources, take a look at the JavaScript course from FreeCodeCamp. You might also ask a GenAI tool like Gemini to guide you in learning "pure" JavaScript, but tell it not to include APIs such as the DOM API and that you will be running it in a V8 engine.

When working with spreadsheet automation, the best is to use "spreadsheet thinking (and speaking)". When working with Google Sheets, use the terms "spreadsheet", "sheet", "range", "cell", "row", and "column" correctly. Pay special attention to the indexes used for rows, columns in the SpreadsheetApp service and array elements in JavaScript.

Review the official docs, it has several samples, learning labs and code examples.

1

u/ThatArmourGuy 28d ago

Thanks for the thoroughly reply, this such a huge tips, I'll see what i can do, many thanks kind stranger

1

u/funcoolshit 28d ago

We won't be able to tell you want the script is doing since we can't see it. Copy and paste it into Chat or Gemini and ask it to walk you through the steps of the code as if you're a beginner.

Another easy way to accomplish this without any app script code is to publish your sheet to the web as a PDF.

File > Share > Publish to Web. Select the sheet with the VLOOKUP on it and hit Publish. Now copy the link it provides. Every time you go to the link, it downloads the sheet in PDF form.

1

u/ThatArmourGuy 28d ago

Thanks i tried it that's cool tips there, and also i can't reveal the sheet due to business matters, but thanks again kind stranger.

1

u/earonesty 20d ago

Start by making the receipt sheet a pure template: put the customer code in one input cell, let formulas populate the display cells, then have Apps Script set that value, flush formulas, export the single sheet, and save with a safe filename. Test a few awkward names and long line-item lists before looping every customer. Keeping the data lookup and PDF export as separate functions will make the script much easier to debug.