import * as wmill from "https://deno.land/x/windmill@v1.46.2/mod.ts";
/** @param range 'A1' notation or 'R1C1' notation (https://developers.google.com/sheets/api/guides/concepts#cell) */
export async function main(gsheets_auth: wmill.Resource<"gsheets">,
spreadsheetId: string,
range: string
) {
const token = gsheets_auth["token"];
const CLEAR_CELLS_URL =
`https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${range}:clear`;
const response = await fetch(CLEAR_CELLS_URL, {
method: "POST",
headers: {
Authorization: "Bearer " + token,
"Content-Type": "application/json",
},
});
const json = await response.json()
if(json.error) {
const { code, status, message} = json.error
throw Error(`\n${code} ${status} - "${message}"`)
}
return `Cells cleared in the range of '${json.clearedRange}'`;
}
Submitted by adam-kov 769 days ago
import * as wmill from "https://deno.land/x/windmill@v1.46.2/mod.ts";
/** @param range 'A1' notation or 'R1C1' notation (https://developers.google.com/sheets/api/guides/concepts#cell) */
export async function main(gsheets_auth: wmill.Resource<"gsheets">,
sheetId: string,
range: string
) {
const token = gsheets_auth["token"];
const CLEAR_CELLS_URL =
`https://sheets.googleapis.com/v4/spreadsheets/${sheetId}/values/${range}:clear`;
const response = await fetch(CLEAR_CELLS_URL, {
method: "POST",
headers: {
Authorization: "Bearer " + token,
"Content-Type": "application/json",
},
});
const json = await response.json()
if(json.error) {
const { code, status, message} = json.error
throw Error(`\n${code} ${status} - "${message}"`)
}
return `Cells cleared in the range of '${json.clearedRange}'`;
}
Submitted by adam-kov 769 days ago
import * as wmill from "https://deno.land/x/windmill@v1.46.2/mod.ts";
/** @param range 'A1' notation or 'R1C1' notation (https://developers.google.com/sheets/api/guides/concepts#cell) */
export async function main(gsheets_auth: wmill.Resource<"gsheets">,
sheetId: string,
range: string
) {
const token = gsheets_auth["token"];
const CLEAR_CELLS_URL =
`https://sheets.googleapis.com/v4/spreadsheets/${sheetId}/values/${range}:clear`;
const response = await fetch(CLEAR_CELLS_URL, {
method: "POST",
headers: {
Authorization: "Bearer " + token,
"Content-Type": "application/json",
},
});
const json = await response.json()
return `Cells cleared in the range of '${json.clearedRange}'`;
}
Submitted by adam-kov 769 days ago
import * as wmill from "https://deno.land/x/windmill@v1.24.1/mod.ts";
export async function main(gsheets_auth: wmill.Resource<"gsheets">,
spreadsheetId: string,
sheetId: number,
// 'A1' notation or 'R1C1' notation (https://developers.google.com/sheets/api/guides/concepts#cell)
range: string
) {
const token = gsheets_auth["token"];
const CLEAR_CELLS_URL =
`https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${range}:clear`;
const response = await fetch(DELETE_ROWS_URL, {
method: "POST",
headers: {
Authorization: "Bearer " + token,
"Content-Type": "application/json",
},
});
const json = await response.json()
return `Cells cleared in the range of '${json.clearedRange}'`;
}
Submitted by adam-kov 772 days ago