mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(Google Sheets Node): Fix for append operation if no empty rows in sheet
This commit is contained in:
@@ -187,6 +187,43 @@ export class GoogleSheet {
|
||||
return response;
|
||||
}
|
||||
|
||||
async appendEmptyRowsOrColumns(sheetId: string, rowsToAdd = 1, columnsToAdd = 1) {
|
||||
const requests: IDataObject[] = [];
|
||||
|
||||
if (rowsToAdd > 0) {
|
||||
requests.push({
|
||||
appendDimension: {
|
||||
sheetId,
|
||||
dimension: 'ROWS',
|
||||
length: rowsToAdd,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (columnsToAdd > 0) {
|
||||
requests.push({
|
||||
appendDimension: {
|
||||
sheetId,
|
||||
dimension: 'COLUMNS',
|
||||
length: columnsToAdd,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (requests.length === 0) {
|
||||
throw new Error('Must specify at least one column or row to add');
|
||||
}
|
||||
|
||||
const response = await apiRequest.call(
|
||||
this.executeFunctions,
|
||||
'POST',
|
||||
`/v4/spreadsheets/${this.id}:batchUpdate`,
|
||||
{ requests },
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the cell values
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user