我想知道如何使用autoResizeDimensions爲了設置列自動調整大小。下面Java Google表格API示例autoResizeDimensionsRequest
List<Request> requests = new ArrayList<>();
AutoResizeDimensionsRequest autoResizeDimensions = new AutoResizeDimensionsRequest();
requests.add(new Request()
.setAutoResizeDimensions(autoResizeDimensions));
BatchUpdateSpreadsheetRequest batchUpdateRequest = new BatchUpdateSpreadsheetRequest()
.setRequests(requests);
SHEETS.spreadsheets().batchUpdate(spreadsheetId, batchUpdateRequest)
.execute();
返回以下錯誤消息
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid requests[1].autoResizeDimensions: Only the COLUMNS dimension is supported",
"reason" : "badRequest"
} ],
"message" : "Invalid requests[1].autoResizeDimensions: Only the COLUMNS dimension is supported",
"status" : "INVALID_ARGUMENT"
我也有興趣在設置特定寬度的列。我還沒有找到任何使用java的例子。如果有人遇到過,或者知道如何不喜歡它。
此外,我已經添加setDimensions該代碼
DimensionRange dimensions = new DimensionRange().setDimension("A1:C6");
與setAutoResizeDimensions
requests.add(new Request()
.setAutoResizeDimensions(autoResizeDimensions
.setDimensions(dimensions)));
但我發現了以下錯誤
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid value at 'requests[3].auto_resize_dimensions.dimensions.dimension' (TYPE_ENUM), \"A1:C6\"",
"reason" : "badRequest"
} ],
"message" : "Invalid value at 'requests[3].auto_resize_dimensions.dimensions.dimension' (TYPE_ENUM), \"A1:C6\"",
"status" : "INVALID_ARGUMENT"
感謝 康特
什麼上面沒有按不工作? –
@SamBerlin,我做了一些修改。希望它更清楚。 – conteh