libreoffice-writer
自動化 LibreOffice Writer 文件
手動編輯文件耗時且容易出錯。此技能透過 UNO 整合自動化 LibreOffice Writer 操作,實現程式化文件建立、編輯、格式化及匯出。
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「libreoffice-writer」。 Create a new document with a title and export to PDF
預期結果:
- Document created successfully: /path/to/report.odt
- Exported to PDF: /path/to/report.pdf
正在使用「libreoffice-writer」。 Find and format text in existing document
預期結果:
- Opened document: /path/to/draft.odt
- Formatted text range: bold, center-aligned
- Changes saved and document closed
正在使用「libreoffice-writer」。 Apply patch with multiple operations
預期結果:
- Patch parsed: 3 operations
- Operation 1 (replace_text): success
- Operation 2 (format_text): success
- Operation 3 (insert_table): success
- Overall status: ok
- Document persisted: true
安全審計
低風險Static analysis flagged 175 patterns but evaluation confirms these are false positives. The skill legitimately uses subprocess to launch LibreOffice with hardcoded arguments, tempfile for secure temp directories, and importlib for module detection. All external command usage has no user input injection vectors. Risk is low due to filesystem and external command dependencies requiring LibreOffice installation.
低風險問題 (3)
風險因素
⚙️ 外部命令 (1)
📁 檔案系統存取 (2)
🔑 環境變數 (1)
品質評分
你能建構什麼
自動化報告生成
透過建立文件、插入格式化文字和表格,然後匯出至 PDF 進行分發,生成標準化報告。
文件範本處理
載入範本文件,使用動態內容替換預留位置文字,使用新資料更新表格,並匯出自訂版本。
批次文件作業
使用具有失敗時原子性回滾的修補程式工作流程,對多個文件套用一致的格式變更。
試試這些提示
在 /path/to/report.odt 建立新的 LibreOffice Writer 文件。插入標題「Monthly Report」,新增區段標題「Summary」,然後插入描述本月成就的段落。將最終文件匯出為 PDF。
開啟 /path/to/draft.odt 並找到出現在「Financial Overview」之後且在「Next Steps」之前的句子「Quarterly revenue grew significantly」。將其設為粗體並置中對齊。然後在「Action Items」之後插入一個包含三個任務的項目符號列表:Review budget、Schedule meeting、Send updates。
開啟 /path/to/data-report.odt 中的文件。插入一個名為「Sales Data」的 4 列 3 欄表格。使用標題 [Region, Q1, Q2] 和 North、South、East 區域的資料列填充表格。日後有新數字時更新 Q2 值。
在原子模式下對 /path/to/manuscript.odt 套用此修補程式:首先,將所有「Draft」替換為「Final」。其次,將章節標題格式化為 14pt 粗體。第三,插入目錄。如果任何作業失敗,回滾所有變更並報告錯誤。
最佳實務
- 使用 UNO 型 Writer API 時務必使用絕對檔案路徑
- 使用完整句子或段落層級片語作為錨點文字目標,而非單一單詞
- 當相同文字可能多次出現時,使用 after 和 before 邊界來限制搜尋範圍
- 將會話作業包裝在 try/finally 或內容管理員中以確保正確清理
- 在切換到原子模式用於生產環境之前,先在 best_effort 模式下測試修補程式工作流程
避免
- 使用相對路徑 - UNO 需要所有文件作業使用絕對檔案路徑
- 當相同文字在文件中多次出現時省略 occurrence 參數
- 在 session.close() 被呼叫後繼續呼叫會話方法
- 在修補程式項目或資料欄位中提供格式錯誤的 JSON
- 期望段落對齊僅套用於相符文字而非整個段落