Một chút trễ, nhưng đây là đoạn trích tiện dụng để thực hiện việc này bằng cách gọi API V4 từ trong Google Apps Script.
Để làm việc này:
Bạn sẽ cần phải kích hoạt các Sheets v4 API trong Google Cloud Console của bạn cho dự án Google Apps Script ràng buộc của Tấm, mà bạn có thể nhận được từ bên trong trình biên tập Script , từ Resources-> dự án nền tảng đám mây ...
Bạn sẽ có khả năng cũng cần phải kích hoạt các Sheets API Resources-> dịch vụ V4 nâng cao của Google ...
function test() {
var spreadsheetId = SpreadsheetApp.getActive().getId();
var sheetId = SpreadsheetApp.getActiveSheet().getSheetId();
hideGridlines(spreadsheetId, sheetId, false);
}
/**
* Hide or show gridlines
*
* @param {string} spreadsheetId - The spreadsheet to request.
* @param {number} sheetId - The ID of the sheet.
* @param {boolean} hideGridlines - True if the grid shouldn't show gridlines in the UI.
**/
function hideGridlines(spreadsheetId, sheetId, hideGridlines) {
var resource = {
"requests": [
{
"updateSheetProperties": {
"fields": "gridProperties(hideGridlines)",
"properties": {
"sheetId": sheetId,
"gridProperties": {
"hideGridlines": hideGridlines
}
}
}
}
],
"includeSpreadsheetInResponse": false,
"responseIncludeGridData": false,
}
Sheets.Spreadsheets.batchUpdate(resource, spreadsheetId)
}
Nguồn
2018-02-08 03:34:08
Chức năng này tốt hơn. function hideGridline (trang tính, hàng, cols) { cho (var i = 1; i <= hàng; i ++) cho (var j = 1; j <= cols; j ++) sheet.getRange (i, j). setBorder (true, true, true, true, false, false, "white", SpreadsheetApp.BorderStyle.SOLID); } – tbernardes