1
0

LibreOfficeCalc: Python のマクロを作成、実行

Last updated at Posted at 2024-08-02

プログラム

フォルダーの作成

cd .config/libreoffice/4/user
mkdir -p Scripts/python
.config/libreoffice/4/user/Scripts/python/hello_world.py
import uno

def hello_world():
    doc = XSCRIPTCONTEXT.getDocument()
    cell = doc.Sheets[0]['A1']
    cell.setString('12')
    cell = doc.Sheets[0]['B2']
    cell.setString('34')
    cell = doc.Sheets[0]['C3']
    cell.setString('56')
    cell = doc.Sheets[0]['C4']
    cell.setString('78')
    cell = doc.Sheets[0]['C5']
    cell.setString('910')
#
    cell = doc.Sheets[0]['E1']
    cell.setString('PythonからCalcでHello World Aug/2/2024')
    return

実行

ツール -> マクロ -> マクロの管理 -> Python(A)

image.png

実行結果

image.png

参考ページ

LibreOffice: Python のマクロを使う

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0