Apps Script
을 사용하고 으로 내용을 변환 한 결과를 표시하는 Google Sheet
에 Sidebar
을 만들려고합니다. Apps 스크립트를 사용하여 HtmlOutput에서 html 콘텐츠 조작
이
페이지Sidebar
에 대한 HTML이다 : 나는 이전에 만든
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<!-- The CSS package above applies Google styling to buttons and other elements. -->
<style>
.width-100 {
width: 100%;
height: 100%
}
</style>
</head>
<body>
<div class="sidebar branding-below">
<form>
<div class="block form-group">
<label for="json"><b>JSON</b></label>
<textarea class="width-100" id="json" name="json" rows="10"></textarea>
</div>
</form>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
</body>
</html>
JSON
원하는 이제이 방법을 사용하여 생성 된 JSON
로 textarea
의 내용을 설정하려고 시도하고있다 :
function displayText_(text) {
var html = HtmlService.createHtmlOutputFromFile('Sidebar')
.setTitle('JSON Results');
var contents = html.getContent();
contents.getElementById('json').setText(text);
html.setContent(contents);
SpreadsheetApp.getUi().showSidebar(html);
}
을
다음은 답변과 함께 사용되는 JSON
문자열입니다.
var jsonString = {"someKey":"someValue","anotherKey":"anotherValue"}
나는 html
과 contents
에 연결하여 getElementById
을 사용해 보았습니다. (현재의 방법). 원하는 결과를 얻을 수있는 것은 없습니다. 나는 이것이 매우 간단하다고 생각하지만, html을 조작하는 방법을 모른다. Apps Script
.
나는 Apps Script
안에 전체 html 콘텐츠를 만들고 콘텐츠를 대체 할 수 있다고 확신하지만 유지 보수가 쉽지 않습니다.
더 쉬운 방법이 있나요?
나는 그것이 쉬울 것이라고 생각했다. 감사! – davids