1 | type Gsheets = { |
2 | token: string; |
3 | }; |
4 | export async function main( |
5 | gsheets_auth: Gsheets, |
6 | spreadsheetId: string, |
7 | sheetId: number, |
8 | start_index: number, |
9 | end_index: number, |
10 | ) { |
11 | const token = gsheets_auth["token"]; |
12 |
|
13 | const DELETE_ROWS_URL = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}:batchUpdate`; |
14 |
|
15 | const body = { |
16 | requests: [ |
17 | { |
18 | deleteDimension: { |
19 | range: { |
20 | sheetId: sheetId, |
21 | dimension: "ROWS", |
22 | startIndex: start_index, |
23 | endIndex: end_index, |
24 | }, |
25 | }, |
26 | }, |
27 | ], |
28 | }; |
29 | const response = await fetch(DELETE_ROWS_URL, { |
30 | method: "POST", |
31 | body: JSON.stringify(body), |
32 | headers: { |
33 | Authorization: "Bearer " + token, |
34 | "Content-Type": "application/json", |
35 | }, |
36 | }); |
37 | const text = await response.json(); |
38 |
|
39 | return "Rows deleted."; |
40 | } |
41 |
|