小编Lou*_*NNE的帖子

仅使用google电子表格API删除单元格区域选择中的格式化

我正在寻找一种方法,只使用带有python的Google表格API来删除单元格范围选择的格式,而不是其内容.

目前,我唯一的解决方案是应用与普通格式相同的逻辑并将样式设置为NONE.例如,当我将边框格式设置为特定范围时,我使用:

    request_dict = {'requests': [{
                    "updateBorders": {
                      "range": {
                        "sheetId": sheetId,
                        "startRowIndex": 1,
                        "endRowIndex": raws,
                        "startColumnIndex": first_col,
                        "endColumnIndex": last_col},
                      "top": {
                        "style": "SOLID_MEDIUM",
                        "width": 1,
                        "color": {"blue": 0}},
                      "bottom": {
                        "style": "SOLID_MEDIUM",
                        "width": 1,
                        "color": {"blue": 0}},
                      "left": {
                        "style": "SOLID_MEDIUM",
                        "width": 1,
                        "color": {"blue": 0}},
                      "right": {
                        "style": "SOLID_MEDIUM",
                        "width": 1,
                        "color": {"blue": 0}},
                      "innerHorizontal": {
                        "style": "SOLID_MEDIUM",
                        "width": 1,
                        "color": {"blue": 0}},
                      "innerVertical": {
                        "style": "SOLID_MEDIUM",
                        "width": 1,
                        "color": {"blue": 0}}}}]}
body = {'requests': request_dict['requests']}
service.spreadsheets().batchUpdate(spreadsheetId=spreadsheetId,
                                   body=body).execute() …
Run Code Online (Sandbox Code Playgroud)

python google-spreadsheet-api

15
推荐指数
2
解决办法
546
查看次数

标签 统计

google-spreadsheet-api ×1

python ×1