Numbersの表の選択範囲のデータを指定の数(10,000とか、100万とか)で切り捨てるAppleScriptです。Numbers v14.3で検証してありますが、凝った機能は何も使っていないので、古いバージョンのNumbersでも問題なく動作することでしょう。
もともとは、Keynoteで作った資料でデータが細かくて見にくかったので、指定桁で切り捨て(100万円で切り捨て、など)するために作ったものです。
本来はiWorkアプリ上でこうした操作を行うには、「データフォーマット」で「カスタムフォーマット」を定義するのがiWorkの流儀です。
ただ、このカスタムフォーマットが割と遠回りでわかりにくかったので(+AppleScriptから操作できないので)、即物的にデータを編集するプログラムを作ってしまった次第です。割と、使い捨てレベルの素朴なScriptでもあります。
AppleScript名:選択範囲のデータを100万円で切り捨て.scpt |
— – Created by: Takaaki Naganoya – Created on: 2025/01/19 — – Copyright © 2025 Piyomaru Software, All Rights Reserved — set calcNum to 10000 tell application "Numbers" tell front document tell active sheet tell table 1 set aSel to cell of selection range set newList to {} repeat with i in aSel set j to contents of i if j is not equal to missing value then set tmpV1 to (value of j) if tmpV1 is not equal to missing value then set tmpV2 to tmpV1 div calcNum ignoring application responses set value of j to tmpV2 end ignoring end if end if end repeat end tell end tell end tell end tell |
More from my site
(Visited 2 times, 2 visits today)