私はPythonでGoogleシートAPIを使用して、コンテンツではなくセル範囲の選択でformatingを削除する方法を探しています。googleスプレッドシートAPIを使用してセル範囲の選択でformatingのみを削除します
私の唯一の解決策は、通常のフォーマットと同じロジックを適用し、スタイルを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()
そして、私はそれを削除したい場合は、私はちょうどこのような「NONE」で「スタイル」フィールドを置き換えます:私はspecifical範囲に境界線の書式を設定する場合たとえば、私が使用し
request_dict = {'requests': [{
"updateBorders": {
"range": {
"sheetId": sheetId,
"startRowIndex": 1,
"endRowIndex": raws,
"startColumnIndex": first_col,
"endColumnIndex": last_col},
"top": {
"style": "NONE",
"width": 1,
"color": {"blue": 0}},
"bottom": {
"style": "NONE",
"width": 1,
"color": {"blue": 0}},
"left": {
"style": "NONE",
"width": 1,
"color": {"blue": 0}},
"right": {
"style": "NONE",
"width": 1,
"color": {"blue": 0}},
"innerHorizontal": {
"style": "NONE",
"width": 1,
"color": {"blue": 0}},
"innerVertical": {
"style": "NONE",
"width": 1,
"color": {"blue": 0}}}}]}
body = {'requests': request_dict['requests']}
service.spreadsheets().batchUpdate(spreadsheetId=spreadsheetId,
body=body).execute()
しかし、それは私が定義した各種類の書式に対して書式を消去する関数を定義する必要があることを意味しています。実際にはそうではありません。 最初の手順はシート全体の書式を消去する方法、多分私のシートの特定の範囲のためにそれを行うことができるようにした後。
私は手掛かりがありません...しかし、フォーマットされていない既知のセルからフォーマットをコピーできるかもしれません。 –