Sheets API appendValues does not use newAppendCellsRequest() and range parameter need clarification.
@jpoehnelt đang làm issue này rồi.
Từ ngày 14/2/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
The Google Apps Script snippet for Sheets API Snippets.prototype.appendValues() does not use the provided Sheets.newAppendCellsRequest() sheetId and rows properties.
See
Further, the parameter range JSdoc definition is unclear. It is recommended that the definition be copied from the documentation:
The A1 notation of a range to search for a logical table of data
There are a number of issues with the Sheets.newAppendCellsRequest() that I have raised in the issue tracker here.
Two possible solutions
Both include updated JSDoc descriptions
1. Includes newAppendCellsRequest() correctly in request.
/**
* Appends values to the specified range
* @param {string} spreadsheetId spreadsheet's ID
* @param {string} range The A1 notation of a range to search for a logical table of data.
* @param valueInputOption determines how the input should be interpreted
* @see
* https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
* @param {*[][]} _values list of rows of values to input
* @returns {*} spreadsheet with appended values
*/
Snippets.prototype.appendValues = (spreadsheetId, range,
valueInputOption, _values) => {
let values = [
[
// Cell values ...
]
// Additional rows ...
];
// [START_EXCLUDE silent]
values = _values;
// [END_EXCLUDE]
try {
let valueRange = Sheets.newRowData();
valueRange.values = values;
let appendRequest = Sheets.newAppendCellsRequest();
appendRequest.sheetId = spreadsheetId;
appendRequest.rows = valueRange;
const result = Sheets.Spreadsheets.Values.append(
appendRequest.rows,
appendRequest.sheetId,
range,
{ valueInputOption: valueInputOption }
);
return result;
} catch (err) {
// TODO (developer) - Handle exception
console.log('Failed with error %s', err.message);
}
};
2. Without newAppendCellsRequest()
/**
* Appends values to the specified range
* @param {string} spreadsheetId spreadsheet's ID
* @param {string} range The A1 notation of a range to search for a logical table of data.
* @param valueInputOption determines how the input should be interpreted
* @see
* https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
* @param {*[][]} _values list of rows of values to input
* @returns {*} spreadsheet with appended values
*/
Snippets.prototype.appendValues = (spreadsheetId, range,
valueInputOption, _values) => {
let values = [
[
// Cell values ...
]
// Additional rows ...
];
// [START_EXCLUDE silent]
values = _values;
// [END_EXCLUDE]
try {
let valueRange = Sheets.newRowData();
valueRange.values = values;
const result = Sheets.Spreadsheets.Values.append(valueRange, spreadsheetId,
range, {valueInputOption: valueInputOption});
return result;
} catch (err) {
// TODO (developer) - Handle exception
console.log('Failed with error %s', err.message);
}
};
- Ngôn ngữ chính
- JavaScript
- Star
- 5.2k
- Fork
- 2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleworkspace/apps-script-samples
-
Alvin Litana Mirasol Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
googleworkspace/apps-script-samples#659 · 1 bình luận · 1 reaction ·
-
Password reset Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
googleworkspace/apps-script-samples#654 · 2 reaction ·
-
cod gs Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
googleworkspace/apps-script-samples#651 · 1 reaction ·
-
tespogrome Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
googleworkspace/apps-script-samples#624 · 1 reaction ·
-
Get_order_manually.gs Đang mở
googleworkspace/apps-script-samples#616 · 1 người được giao ·
Tất cả issue của googleworkspace/apps-script-samples
Issue tương tự
-
Update HugeIcons library Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
antfu-collective/icones#398 ·
-
ECmail.com Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
wesbos/burner-email-providers#554 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
components-web-app/docs#92 ·