-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_selected_cell_content.js
More file actions
49 lines (43 loc) · 1.21 KB
/
show_selected_cell_content.js
File metadata and controls
49 lines (43 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('🔍 Перегляд')
.addItem('Показати повний вміст клітинки', 'showSelectedCellContent')
.addToUi();
}
function showSelectedCellContent() {
const range = SpreadsheetApp.getActiveRange();
if (!range) {
SpreadsheetApp.getUi().alert('Спочатку вибери клітинку.');
return;
}
const sheet = range.getSheet();
const content = range.getDisplayValue();
if (!content) {
SpreadsheetApp.getUi().alert('Ця клітинка порожня.');
return;
}
const html = HtmlService.createHtmlOutput(`
<div style="
font-family:Arial, sans-serif;
padding:15px;
line-height:1.5;
white-space:pre-wrap;
word-wrap:break-word;
max-height:500px;
overflow:auto;
">
<div>${escapeHtml(content)}</div>
<hr>
</div>
`).setWidth(600).setHeight(400);
SpreadsheetApp.getUi().showModalDialog(html, 'Повний вміст');
}
function escapeHtml(text) {
return text
.toString()
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}