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