I tried to add columns in my Google Sheet, using this . But I always get error UnhandledPromiseRejectionWarning: TypeError: doc.updateDimensionProperties is not a function
Here is my code:
const doc = new GoogleSpreadsheet('google-id');
async function updateTable(token){
await doc.useServiceAccountAuth(require('./credentials.json'));
await doc.updateDimensionProperties("COLUMNS", 5, 1);
}
I believe your goal and your situation as follows.
updateDimensionProperties()
using google-spreadsheet .updateDimensionProperties()
is required to be used for sheet
object. Ref updateDimensionProperties()
are columnsOrRows
, props
, bounds
, bounds.startIndex
and bounds.endIndex
.When above points are reflected to your script, it becomes as follows.
await doc.useServiceAccountAuth(require('./credentials.json')); await doc.updateDimensionProperties("COLUMNS", 5, 1);
To:
await doc.useServiceAccountAuth(require('./credentials.json')); await doc.loadInfo(); const sheet = doc.sheetsByIndex[0]; await sheet.updateDimensionProperties("COLUMNS", { pixelSize: 200 }, { startIndex: 2, endIndex: 3 });
props
of updateDimensionProperties()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.