diff --git a/docs/classes/google-spreadsheet-worksheet.md b/docs/classes/google-spreadsheet-worksheet.md index b413018f..80cb8624 100644 --- a/docs/classes/google-spreadsheet-worksheet.md +++ b/docs/classes/google-spreadsheet-worksheet.md @@ -240,6 +240,24 @@ Param|Type|Required|Description ---|---|---|--- `range`|Object
[GridRange](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#GridRange)]|✅|Range of cells to unmerge, sheetId not required! +#### `pasteData(coordinate, data, delimiter)` (async) :id=fn-pasteData +> Inserts data into the spreadsheet starting at the specified coordinate. + +Param|Type|Required|Description +---|---|---|--- +`coordinate`|[[GridCoordinate](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#GridCoordinate)]|✅|The coordinate at which the data should start being inserted, sheetId not required! +`data`|String|✅|The data to insert. +`delimiter`|String|✅|The delimiter in the data. +`type`|String (enum)
[PasteType](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#PasteType)|-|How the data should be pasted. _defaults to `PASTE_NORMAL`_ + +#### `appendDimension(dimension, length)` (async) :id=fn-appendDimension +> Appends rows or columns to the end of a sheet. + +Param|Type|Required|Description +---|---|---|--- +`dimension`|[[Dimension](https://developers.google.com/sheets/api/reference/rest/v4/Dimension)]|✅|Whether rows or columns should be appended. +`length`|number|✅|The number of rows or columns to append. + ### Updating Sheet Properties #### `updateProperties(props)` (async) :id=fn-updateProperties diff --git a/lib/GoogleSpreadsheetWorksheet.js b/lib/GoogleSpreadsheetWorksheet.js index cbc33ac4..bbd30d83 100644 --- a/lib/GoogleSpreadsheetWorksheet.js +++ b/lib/GoogleSpreadsheetWorksheet.js @@ -697,9 +697,19 @@ class GoogleSpreadsheetWorksheet { // https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#UpdateEmbeddedObjectPositionRequest } - async pasteData() { + async pasteData(coordinate, data, delimiter, type = "PASTE_NORMAL") { // Request type = `pasteData` // https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#PasteDataRequest + await this._makeSingleUpdateRequest("pasteData", { + coordinate: { + rowIndex: coordinate.rowIndex, + columnIndex: coordinate.columnIndex, + sheetId: this.sheetId, + }, + data, + delimiter, + type + }); } async textToColumns() { @@ -717,9 +727,14 @@ class GoogleSpreadsheetWorksheet { // https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#DeleteRangeRequest } - async appendDimension() { + async appendDimension(dimension, length) { // Request type = `appendDimension` // https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#AppendDimensionRequest + await this._makeSingleUpdateRequest("appendDimension", { + sheetId: this.sheetId, + dimension, + length, + }); } async addConditionalFormatRule() {