LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Sunday, September 24, 2023

New line removal App using Google Apps Script


Introduction

This is a simple application for removing new lines from the input textarea to the output textarea.


Application

After typing in the input text area, if you click on the output text area, the text will be input with line breaks removed.

Sample App




Source Code


Code.gs
function doGet() {
return HtmlService.createTemplateFromFile('index')
.evaluate()
.setTitle("Title");
}

function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}

index.html
<!DOCTYPE html>
<html>
<head>
<?!= include("css"); ?>
</head>
<body>
<textarea id="input"></textarea>
<br>
<textarea id="output"></textarea>
<?!= include("javascript"); ?>
</body>
</html>

css.html
<style>
textarea {
width: 90vw;
height: 40vh;
}
</style>

javascript.html
<script>
function elem(id) {
return document.getElementById(id);
}

elem("input").onchange = inputChanged;

function inputChanged() {
elem("output").value = elem("input").value.replace(/\n/g, "");
}
</script>



Latest post

スプレッドシートA列にある複数のテキストをスライドに追加したい(Google Apps Script)

今回Google Apps Scriptでやりたいこと GoogleスプレッドシートA列にある複数の値を取得して Googleスライドに渡して 図形オブジェクトのテキストとして追加したい ① スプレッドシートのA列に値を入れておく ② Code.gsのinsertNewShape...