This repository has some functions to help with Google Apps Script
git clone https://github.com/kuuhack/google-apps-script-utils.git
cd google-apps-script-utils
yarn install
yarn clasp login
yarn clasp create --rootDir ./src/ --title utils
yarn clasp push -f
A | B | C | |
---|---|---|---|
1 | name | age | favorite |
2 | hoge | 20 | curry |
3 | fuga | 30 | chocolate |
4 | piyo | 40 | coffee |
const myFunction = () => {
const sheet = SpreadsheetApp.getActiveSheet()
const values = sheet.getDataRange().getValues()
const objects = createObjects(values)
console.log(objects)
// [ { name: 'hoge', age: 20, favorite: 'curry' },
// { name: 'fuga', age: 30, favorite: 'chocolate' },
// { name: 'piyo', age: 40, favorite: 'coffee' } ]
console.log(objects.filter((object) => object.name === 'fuga')[0])
// { name: 'fuga', age: 30, favorite: 'chocolate' }
const newValues = createValues(objects)
console.log(newValues)
// [ [ 'name', 'age', 'favorite' ],
// [ 'hoge', 20, 'curry' ],
// [ 'fuga', 30, 'chocolate' ],
// [ 'piyo', 40, 'coffee' ] ]
console.log(newValues.filter((record) => record.includes('fuga'))[0])
// [ 'fuga', 30, 'chocolate' ]
}
A | B | |
---|---|---|
1 | hoge | 10 |
2 | fuga | 20 |
3 | piyo | 20 |
const myFunction = () => {
const sheet = SpreadsheetApp.getActiveSheet()
const values = sheet.getDataRange().getValues()
const object = createObjects(values)
console.log(object)
// { hoge: 10, fuga: 20, piyo: 20 }
}
const myFunction = () => {
const sheet = SpreadsheetApp.getActiveSheet()
const array = createArray(sheet)
console.log(array)
// [{ hoge: 10, fuga: 20, piyo: 20 }, { hoge: 30, fuga: 40, piyo: 40 }]
}
const myFunction = () => {
const baseUrl = 'https://example.com'
const params = { id: 1, name: 'fuga' }
const url = constructUrl(baseUrl, params)
console.log(url)
// 'https://example.com?id=1&name=fuga'
}
A | B | C | |
---|---|---|---|
1 | name | age | favorite |
2 | hoge | 20 | curry |
3 | fuga | 30 | chocolate |
4 | piyo | 40 | coffee |
const myFunction = () => {
const sheet = SpreadsheetApp.getActiveSheet()
const row = searchRow(sheet, 'fuga')
console.log(row)
// [3]
}
URL parser imported from URI.js. Please follow the URL below for usage.
coming soon...