質問編集履歴
2
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
builder.setTextStyle(startOffset, endOffset, newStyle);
|
29
29
|
}
|
30
30
|
}
|
31
|
-
hairetsu.push([
|
31
|
+
hairetsu.push([builder.build()])
|
32
32
|
}
|
33
33
|
range.setRichTextValues(hairetsu);
|
34
34
|
}
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,21 +11,26 @@
|
|
11
11
|
const sheet = file.getSheetByName("RichText");
|
12
12
|
const range = sheet.getRange(2,1,sheet.getLastRow());
|
13
13
|
const richTextValues = range.getRichTextValues();
|
14
|
+
const hairetsu = [];
|
14
15
|
for (let row=2; row<richTextValues.length; row++) {
|
15
16
|
const rtv = richTextValues[row][0];
|
17
|
+
// 既存のスタイルから RichTextValueBuilder を作成
|
16
18
|
const builder = rtv.copy();
|
19
|
+
// 書式部分ごとにループ処理
|
17
20
|
for (const run of rtv.getRuns()) {
|
18
21
|
if (run.getTextStyle().isItalic()) {
|
19
22
|
run.getTextStyle().isItalic(false);
|
20
23
|
run.getTextStyle().isBold(true);
|
21
24
|
const newStyle = run.getTextStyle().build();
|
25
|
+
// 現在の書式部分に対して新しい TextStyle を設定
|
22
26
|
const startOffset = run.getStartIndex();
|
23
27
|
const endOffset = run.getEndIndex();
|
24
28
|
builder.setTextStyle(startOffset, endOffset, newStyle);
|
25
29
|
}
|
26
30
|
}
|
31
|
+
hairetsu.push([***])
|
27
32
|
}
|
28
|
-
range.setRichTextValues(
|
33
|
+
range.setRichTextValues(hairetsu);
|
29
34
|
}
|
30
35
|
```
|
31
36
|
|