2017-04-18 5 views

답변

0

다음 GAS 샘플은 어떻습니까? GAS를 제외하고 달리기를 원한다면 말해주십시오.

이 기능을 사용하려면 먼저 고급 Google 서비스 및 Google API 콘솔의 Google 시트 API v4를 사용하도록 설정하십시오.

사용 방법은 다음과 같습니다.

스크립트 편집기에서
  1. 에게 자원> 고급 Google 서비스

    대화 상자가 나타나면
  2. Google 스프레드 시트 API의 온/오프 스위치를 클릭합니다.

  3. 대화 상자 하단에서 Google API 콘솔 링크를 클릭하십시오.

  4. 콘솔에서 필터 상자를 클릭하고 API "Google 스프레드 시트 API"의 이름 부분을 입력 한 다음 이름을 클릭합니다.

  5. 다음 화면에서 API 사용을 클릭하십시오.

  6. 개발자 콘솔을 닫고 스크립트 편집기로 돌아갑니다. 대화 상자에서 확인을 클릭하십시오. 사용하도록 설정 한 고급 서비스를 이제 자동 완성으로 사용할 수 있습니다.

세부 정보는 https://developers.google.com/apps-script/guides/services/advanced입니다.

스크립트 :

Sheets.Spreadsheets.create({ 
    "properties": 
    { 
    "title": "filename" // filename 
    }, 
    "sheets": 
    [ 
    { 
     "data": 
     [ 
     { 
      "startRow": 0, // 1st row 
      "startColumn": 7, // column h 
      "rowData": 
      [ 
      { 
       "values": 
       [ 
       { 
        "userEnteredValue": 
        { 
        "stringValue": "sample text h1" 
        } 
       } 
       ] 
      }, 
      { 
       "values": 
       [ 
       { 
        "userEnteredValue": 
        { 
        "stringValue": "sample text h2" 
        } 
       } 
       ] 
      }, 
      { 
       "values": 
       [ 
       { 
        "userEnteredValue": 
        { 
        "stringValue": "sample text h3" 
        } 
       } 
       ] 
      } 
      ] 
     } 
     ] 
    } 
    ] 
}); 

결과 :

enter image description here

내가 긴 JSON 데이터를 줘서 미안 해요. 샘플 텍스트를 변경하십시오. 셀에 번호를 사용하려면 "stringValue" 대신 "numberValue"을 사용하십시오.

질문에 대해 오해 한 경우, 죄송합니다.

은 추가 1 : 스크립트 위

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); 
var range = sheet.getRange('h1:h3'); 
var protection = range.protect().setDescription('protected'); 
var me = Session.getEffectiveUser(); 
protection.addEditor(me); 
protection.removeEditors(protection.getEditors()); 
if (protection.canDomainEdit()) { 
    protection.setDomainEdit(false); 
} 

h1:h3를 보호합니다. 소유자는 모든 셀을 편집 할 수 있지만 다른 사용자는 h1:h3 만 편집 할 수 없습니다.

추가 2 :

Sheets.Spreadsheets.create({ 
    "properties": 
    { 
    "title": "filename" 
    }, 
    "sheets": 
    [ 
    { 
     "protectedRanges": 
     [ 
     { 
      "range": 
      { 
      "startColumnIndex": 7, 
      "endColumnIndex": 8, 
      "startRowIndex": 0, 
      "endRowIndex": 3, 
      "sheetId": 0 
      }, 
      "description": "protected", 
      "editors": 
      { 
      "users": 
      ["your e-mail address" 
      ] 
      } 
     } 
     ], 
     "data": 
     [ 
     { 
      "startColumn": 7, 
      "startRow": 0, 
      "rowData": 
      [ 
      { 
       "values": 
       [ 
       { 
        "userEnteredValue": 
        { 
        "stringValue": "sample text h1" 
        } 
       } 
       ] 
      }, 
      { 
       "values": 
       [ 
       { 
        "userEnteredValue": 
        { 
        "stringValue": "sample text h2" 
        } 
       } 
       ] 
      }, 
      { 
       "values": 
       [ 
       { 
        "userEnteredValue": 
        { 
        "stringValue": "sample text h3" 
        } 
       } 
       ] 
      } 
      ] 
     } 
     ], 
     "properties": 
     { 
     "sheetId": 0 
     } 
    } 
    ] 
}); 

이 스크립트는 새 스프레드 시트를 만들 수 있습니다. 이 때 'h1 : h3'에 데이터를 추가하고 보호합니다. 전자 메일 주소를 편집기로 추가하십시오. 이것은 Google Sheet API v4에서 사용됩니다.

+0

정말 도움이됩니다. 정말 고맙습니다. 시트를 만드는 동안이 세 가지 값 H1, H2, H3을 편집 할 수 없도록 만드는 방법을 알려 주실 수 있습니까? –

+0

클래스 보호를 사용할 수 있습니다. 여기에서 세부 정보를 볼 수 있습니다. https://developers.google.com/apps-script/reference/spreadsheet/protection – Tanaike

+0

이 참조가 도움이 될 것이라고 생각하지만 SpreadsheetApp 클래스의 출처와 위의 코드에서이를 통합하는 방법을 찾을 수 없습니다. 저를 도와주세요? –