技能 libreoffice-calc
📊

libreoffice-calc

低風險 ⚙️ 外部命令📁 檔案系統存取🔑 環境變數

使用 UNO 自動化 LibreOffice Calc 試算表

手動編輯試算表既繁瑣又容易出錯。此技能透過 UNO API 以程式方式自動化 Calc 操作,實現可靠的批次處理。

支援: Claude Codex Code(CC)
🥉 73 青銅
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「libreoffice-calc」。 Create spreadsheet, add data to range A0:B2, export to PDF

預期結果:

  • Spreadsheet created at /reports/output.ods
  • Data written to range Sheet1.A0:B2 (3 cells)
  • Exported to PDF: /reports/output.pdf (127 KB)

正在使用「libreoffice-calc」。 Read cell B5 from /data/sales.ods

預期結果:

  • Cell Sheet1.B5:
  • Value: 4250.00
  • Type: number
  • Formula: None

正在使用「libreoffice-calc」。 Create bar chart from A0:C10, anchor at row 12

預期結果:

  • Chart 'Sales Overview' created on Sheet1
  • Data range: A0:C10 (11 rows, 3 columns)
  • Position: Row 12, Column 0
  • Dimensions: 8000 x 6000 units

安全審計

低風險
v2 • 3/19/2026

Static analysis flagged 197 patterns across 13 files. After evaluation, all high-severity findings are false positives: cryptographic warnings misidentified UNO connection code, 'system reconnaissance' flagged exception class definitions, and 'dynamic imports' were standard Python import statements. Shell command patterns exist only in markdown documentation. The single confirmed external command (subprocess.Popen launching LibreOffice) uses hardcoded arguments with no user input injection risk. Temp file usage follows Python best practices with proper cleanup. Skill is safe for publication with minor documentation recommended.

13
已掃描檔案
2,642
分析行數
5
發現項
2
審計總數
低風險問題 (2)
Subprocess Launch of External Application
LibreOffice soffice binary launched via subprocess.Popen. Arguments are hardcoded with no user input injection vectors. Process is properly terminated and temp directories cleaned up in finally block.
Temporary Directory Creation
Creates temporary directories for LibreOffice profile isolation using tempfile.mkdtemp. Directories are cleaned up in finally block with shutil.rmtree.

風險因素

審計者: claude 查看審計歷史 →

品質評分

64
架構
100
可維護性
87
內容
23
社群
86
安全
83
規範符合性

你能建構什麼

自動化財務報告

透過填入資料至範本、套用貨幣格式,並為利害關係人簡報建立趨勢圖表,產生月度營收報告。

大量資料匯出與轉換

將資料從資料庫或 API 擷取至結構化試算表,套用驗證規則,並匯出為多種格式以供散發。

範本式文件生成

使用動態資料填入預先設計的試算表範本,產生發票、工時表或庫存報告,並保持一致的格式。

試試這些提示

建立基本試算表
在 /reports/monthly-data.ods 建立新的 Calc 試算表,工作表命名為 'Data'。在第 0 列新增標題 'Name'、'Value'、'Date',然後填入 5 列範例資料。將標題列套用粗體格式,並將 Value 欄套用貨幣格式。
匯出試算表至多種格式
開啟 /reports/monthly-data.ods 並匯出為三種格式:PDF 至 /exports/monthly-data.pdf、Excel 至 /exports/monthly-data.xlsx,以及 CSV 至 /exports/monthly-data.csv。驗證所有匯出成功完成。
建立圖表並搭配資料驗證
在 /reports/sales.ods 中,使用 Sheet1 中 A0:B12 範圍的資料建立標題為 'Monthly Sales' 的折線圖。將圖表錨定在第 15 列、第 0 欄,寬度 8000,高度 6000。隨後在 B 欄新增資料驗證,要求值介於 0 和 10000 之間,錯誤訊息為 'Enter sales between 0 and 10000'。
套用修補程式更新現有報告
以原子模式將此修補程式套用至 /reports/quarterly.ods:使用新的季度資料更新 A0:D4 範圍內的儲存格,使用粗體和背景顏色格式化標題列,建立顯示類別分布的圓餅圖,並重新計算所有公式。如果任何操作失敗,則復原所有變更。

最佳實務

  • 使用 Calc API 時一律使用絕對檔案路徑,以避免解析錯誤
  • 正確關閉工作階段,使用上下文管理程式或明確的 close() 呼叫以釋放 LibreOffice 資源
  • 對應該一起成功或失敗的相關操作使用原子修補模式
  • 寫入儲存格前先驗證資料類型,以防止類型轉換問題

避免

  • 使用 Calc UI 中的一為基礎座標 - API 使用零為基礎索引
  • 混用儲存格和範圍目標 - 即使對單一儲存格,它們也是不同的類型
  • 在 close() 之後呼叫工作階段方法 - 執行操作前務必檢查工作階段狀態
  • 假設圖表名稱是自動產生的 - 一律指定明確的標題以確保可靠的定位

常見問題

使用此技能需要安裝 LibreOffice 嗎?
是的,系統必須安裝 LibreOffice 並具備 UNO Python 綁定。技能會自動偵測常見的安裝路徑,或您可以設定 LIBREOFFICE_PROGRAM_PATH 環境變數。
此技能可以修改 Excel (.xlsx) 檔案嗎?
LibreOffice Calc 可以開啟和儲存 .xlsx 檔案,但主要格式是 .ods。支援匯出至 .xlsx。為獲得最佳相容性,請使用 .ods 格式操作,需要時再匯出。
如何處理儲存格中的公式?
寫入儲存格時設定 value_type='formula' 並提供公式字串(例如 '=SUM(A1:A10)')。讀取儲存格時會傳回公式結果,以及公式文字和任何錯誤狀態。
如果 LibreOffice 在操作期間當機會發生什麼事?
此技能為每個工作階段使用隔離的設定檔目錄。如果發生當機,請手動從 /tmp/libreoffice-skills-* 清理暫存目錄並重新啟動。原子修補模式有助於防止部分更新。
我可以同時執行多個 Calc 工作階段嗎?
是的,每個工作階段使用獨特的管道名稱和隔離的設定檔目錄。不過,執行大量並發工作階段可能會影響系統資源。
為什麼我的座標差一?
API 使用零為基礎索引,而 Calc 的 UI 顯示以一為基礎的列/欄號碼。API 中的第 0 列等於 Calc 中的第 1 列。請據此調整您的座標。

開發者詳情