如果我滚动电子表格,行的标题字段将被隐藏,我需要在同一电子表格中使用粗体文字格式。
问题
我可以通过电子表格api设置冻结行和样式 - 是否可以?
答案 0 :(得分:7)
现在可以在v4 API中使用。
以下是API文档: https://developers.google.com/sheets/reference/rest/v4/spreadsheets#gridproperties
如果您想使用App脚本,也可以: https://developers.google.com/apps-script/reference/spreadsheet/sheet#setFrozenRows(Integer)
这是我用Ruby API发出的请求:
update_sheet_properties: {
properties: {
sheet_id: 'YOUR SHEET ID HERE',
grid_properties: { frozen_row_count: 4 }
},
fields: 'gridProperties.frozenRowCount'
}
答案 1 :(得分:0)
如果有人在寻找使用PHP解决方案来格式化标题并在滚动时冻结标题,那么您可以按照以下方法进行操作:
//$client will be your google service client request after authorization.
$service = new Google_Service_Sheets($client);
$formatRowColrequests = [
new Google_Service_Sheets_Request([
"repeatCell" => [
"range" => [
"sheetId" => $setSheetId, //set your sheet ID
"startRowIndex" => 0,
"endRowIndex" => 1,
"startColumnIndex" => 0,
"endColumnIndex" => 100
],
"cell" => [
"userEnteredFormat" => [
"horizontalAlignment" => "CENTER",
"textFormat" => [
"fontSize" => 9,
"bold" => true
]
]
],
"fields" => "userEnteredFormat(textFormat,horizontalAlignment)"
]
]),
new Google_Service_Sheets_Request([
'updateSheetProperties' => [
'properties' => [
'sheetId' => $setSheetId,
'gridProperties' => [
'frozenRowCount' => 1
]
],
"fields"=> "gridProperties.frozenRowCount"
]
])
];
$batchUpdateCellFormatRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
'requests' => $formatRowColrequests
]);
$service->spreadsheets->batchUpdate($spreadsheetId, $batchUpdateCellFormatRequest);
答案 2 :(得分:0)
这是在android中执行的方法。花了一段时间才弄清楚。该文档仅提供了一些示例[为此]。
if verify_recaptcha
......my contact form is submitted......
else
flash[:danger] = "My custom reCAPTCHA message"
render :home
end