Project Features
- Get Data as a JSON response from Google sheets
- Generate new PDF’s from response data such as invoices or anything you want with your personal template
- Send Email to each user with there generated PDF via SMTP Server
Requirements
NodeJs
must be installedGoogle sheet
setup as described below in thereadme.md
to get data
Project setup
- Clone the repository from github via git on your laptop
git clone https://github.com/9ovindyadav/invoiceGenerator.git
- Rename the
.env.example
file to.env
and enter the credentials - Before running the script make sure you have entered all the credentials in
.env
andGoogle sheet
is all set - To run the app enter the below command
node app.js
Google sheet as a API
- Getting JSON response
- First row as a key and others as a value
- Follow below steps to make google sheets as a API
steps
- Create a New Google worksheet with your google accoount
- Rename Sheet1 as you want
- Fill the data in the sheet as first row as a heading and others as a values
- In
Extension
openApp Script
- Name the
App Script
as the same name as yourworksheet
- Copy paste the below code in
Code.gs
file
function doGet(req){
var sheetName = 'Your sheet name';
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName(sheetName);
var values = sheet.getDataRange().getValues();
var output = [];
var keys = values[0];
var data = values.slice(1);
data.forEach((item) => {
var row = {};
keys.forEach((key, index) => {
row[key] = item[index];
})
output.push(row);
})
console.log(output);
return ContentService.createTextOutput(JSON.stringify({data: output})).setMimeType(ContentService.MimeType.JSON);
}
- Deploy the following code as a
New Deployment
as aweb app
- Allow
Who can access
asAnyone
- Copy the
script link
andrun
inbrowser's address bar
Deployment page
Script link page
Example Googl sheet
Contribuiting
Contributions are welcome! If you’d like to contribute to the project.