LibreOffice Calc
Overview
LibreOffice Calc skill for creating, editing, converting, and automating spreadsheet workflows using the native ODS (OpenDocument Spreadsheet) format.
When to Use This Skill
Use this skill when:
- Creating new spreadsheets in ODS format
- Converting between ODS, XLSX, CSV, PDF formats
- Automating data processing and analysis
- Creating formulas, charts, and pivot tables
- Batch processing spreadsheet operations
Core Capabilities
1. Spreadsheet Creation
- Create new ODS spreadsheets from scratch
- Generate spreadsheets from templates
- Create data entry forms
- Build dashboards and reports
2. Format Conversion
- ODS to other formats: XLSX, CSV, PDF, HTML
- Other formats to ODS: XLSX, XLS, CSV, DBF
- Batch conversion of multiple files
3. Data Automation
- Formula automation and calculations
- Data import from CSV, database, APIs
- Data export to various formats
- Batch data processing
4. Data Analysis
- Pivot tables and data summarization
- Statistical functions and analysis
- Data validation and filtering
- Conditional formatting
5. Integration
- Command-line automation via soffice
- Python scripting with UNO
- Database connectivity
Workflows
Creating a New Spreadsheet
Method 1: Command-Line
soffice --calc template.ods
Method 2: Python with UNO
import uno
def create_spreadsheet():
local_ctx = uno.getComponentContext()
resolver = local_ctx.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", local_ctx
)
ctx = resolver.resolve(
"uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"
)
smgr = ctx.ServiceManager
doc = smgr.createInstanceWithContext("com.sun.star.sheet.SpreadsheetDocument", ctx)
sheets = doc.getSheets()
sheet = sheets.getByIndex(0)
cell = sheet.getCellByPosition(0, 0)
cell.setString("Hello from LibreOffice Calc!")
doc.storeToURL("file:///path/to/spreadsheet.ods", ())
doc.close(True)
Method 3: Using ezodf
import ezodf
doc = ezodf.newdoc('ods', 'spreadsheet.ods')
sheet = doc.sheets[0]
sheet['A1'].set_value('Hello')
sheet['B1'].set_value('World')
doc.save()
Converting Spreadsheets
# ODS to XLSX
soffice --headless --convert-to xlsx spreadsheet.ods
# ODS to CSV
soffice --headless --convert-to csv spreadsheet.ods
# ODS to PDF
soffice --headless --convert-to pdf spreadsheet.ods
# XLSX to ODS
soffice --headless --convert-to ods spreadsheet.xlsx
# Batch convert
for file in *.ods; do
soffice --headless --convert-to xlsx "$file"
done
Formula Automation
import uno
def create_formula_spreadsheet():
local_ctx = uno.getComponentContext()
resolver = local_ctx.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", local_ctx
)
ctx = resolver.resolve(
"uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"
)
smgr = ctx.ServiceManager
doc = smgr.createInstanceWithContext("com.sun.star.sheet.SpreadsheetDocument", ctx)
sheet = doc.getSheets().getByIndex(0)
sheet.getCellByPosition(0, 0).setDoubleValue(100)
sheet.getCellByPosition(0, 1).setDoubleValue(200)
cell = sheet.getCellByPosition(0, 2)
cell.setFormula("SUM(A1:A2)")
doc.storeToURL("file:///path/to/formulas.ods", ())
doc.close(True)
Format Conversion Reference
Supported Input Formats
- ODS (native), XLSX, XLS, CSV, DBF, HTML
Supported Output Formats
- ODS, XLSX, XLS, CSV, PDF, HTML
Command-Line Reference
soffice --headless
soffice --headless --convert-to <format> <file>
soffice --calc # Calc
Python Libraries
pip install ezodf # ODS handling
pip install odfpy # ODF manipulation
pip install pandas # Data analysis
Best Practices
- Use named ranges for clarity
- Document complex formulas
- Use data validation for input control
- Create templates for recurring reports
- Store ODS source files in version control
- Test conversions thoroughly
- Use CSV for data exchange
- Handle conversion failures gracefully
Troubleshooting
Cannot open socket
killall soffice.bin
soffice --headless --accept="socket,host=localhost,port=8100;urp;"
Resources
Related Skills
- writer
- impress
- draw
- base
- xlsx-official
- workflow-automation
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
1---2name: calc3description: Spreadsheet creation, format conversion (ODS/XLSX/CSV), formulas, data automation with LibreOffice Calc.4---567# LibreOffice Calc89## Overview1011LibreOffice Calc skill for creating, editing, converting, and automating spreadsheet workflows using the native ODS (OpenDocument Spreadsheet) format.1213## When to Use This Skill1415Use this skill when:16- Creating new spreadsheets in ODS format17- Converting between ODS, XLSX, CSV, PDF formats18- Automating data processing and analysis19- Creating formulas, charts, and pivot tables20- Batch processing spreadsheet operations2122## Core Capabilities2324### 1. Spreadsheet Creation25- Create new ODS spreadsheets from scratch26- Generate spreadsheets from templates27- Create data entry forms28- Build dashboards and reports2930### 2. Format Conversion31- ODS to other formats: XLSX, CSV, PDF, HTML32- Other formats to ODS: XLSX, XLS, CSV, DBF33- Batch conversion of multiple files3435### 3. Data Automation36- Formula automation and calculations37- Data import from CSV, database, APIs38- Data export to various formats39- Batch data processing4041### 4. Data Analysis42- Pivot tables and data summarization43- Statistical functions and analysis44- Data validation and filtering45- Conditional formatting4647### 5. Integration48- Command-line automation via soffice49- Python scripting with UNO50- Database connectivity5152## Workflows5354### Creating a New Spreadsheet5556#### Method 1: Command-Line57```bash58soffice --calc template.ods59```6061#### Method 2: Python with UNO62```python63import uno6465def create_spreadsheet():66 local_ctx = uno.getComponentContext()67 resolver = local_ctx.ServiceManager.createInstanceWithContext(68 "com.sun.star.bridge.UnoUrlResolver", local_ctx69 )70 ctx = resolver.resolve(71 "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"72 )73 smgr = ctx.ServiceManager74 doc = smgr.createInstanceWithContext("com.sun.star.sheet.SpreadsheetDocument", ctx)75 sheets = doc.getSheets()76 sheet = sheets.getByIndex(0)77 cell = sheet.getCellByPosition(0, 0)78 cell.setString("Hello from LibreOffice Calc!")79 doc.storeToURL("file:///path/to/spreadsheet.ods", ())80 doc.close(True)81```8283#### Method 3: Using ezodf84```python85import ezodf8687doc = ezodf.newdoc('ods', 'spreadsheet.ods')88sheet = doc.sheets[0]89sheet['A1'].set_value('Hello')90sheet['B1'].set_value('World')91doc.save()92```9394### Converting Spreadsheets9596```bash97# ODS to XLSX98soffice --headless --convert-to xlsx spreadsheet.ods99100# ODS to CSV101soffice --headless --convert-to csv spreadsheet.ods102103# ODS to PDF104soffice --headless --convert-to pdf spreadsheet.ods105106# XLSX to ODS107soffice --headless --convert-to ods spreadsheet.xlsx108109# Batch convert110for file in *.ods; do111 soffice --headless --convert-to xlsx "$file"112done113```114115### Formula Automation116```python117import uno118119def create_formula_spreadsheet():120 local_ctx = uno.getComponentContext()121 resolver = local_ctx.ServiceManager.createInstanceWithContext(122 "com.sun.star.bridge.UnoUrlResolver", local_ctx123 )124 ctx = resolver.resolve(125 "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"126 )127 smgr = ctx.ServiceManager128 doc = smgr.createInstanceWithContext("com.sun.star.sheet.SpreadsheetDocument", ctx)129 sheet = doc.getSheets().getByIndex(0)130 131 sheet.getCellByPosition(0, 0).setDoubleValue(100)132 sheet.getCellByPosition(0, 1).setDoubleValue(200)133 134 cell = sheet.getCellByPosition(0, 2)135 cell.setFormula("SUM(A1:A2)")136 137 doc.storeToURL("file:///path/to/formulas.ods", ())138 doc.close(True)139```140141## Format Conversion Reference142143### Supported Input Formats144- ODS (native), XLSX, XLS, CSV, DBF, HTML145146### Supported Output Formats147- ODS, XLSX, XLS, CSV, PDF, HTML148149## Command-Line Reference150151```bash152soffice --headless153soffice --headless --convert-to <format> <file>154soffice --calc # Calc155```156157## Python Libraries158159```bash160pip install ezodf # ODS handling161pip install odfpy # ODF manipulation162pip install pandas # Data analysis163```164165## Best Practices1661671. Use named ranges for clarity1682. Document complex formulas1693. Use data validation for input control1704. Create templates for recurring reports1715. Store ODS source files in version control1726. Test conversions thoroughly1737. Use CSV for data exchange1748. Handle conversion failures gracefully175176## Troubleshooting177178### Cannot open socket179```bash180killall soffice.bin181soffice --headless --accept="socket,host=localhost,port=8100;urp;"182```183184## Resources185186- [LibreOffice Calc Guide](https://documentation.libreoffice.org/)187- [UNO API Reference](https://api.libreoffice.org/)188- [ezodf Documentation](http://ezodf.rst2.org/)189190## Related Skills191192- writer193- impress194- draw195- base196- xlsx-official197- workflow-automation198199## Limitations200- Use this skill only when the task clearly matches the scope described above.201- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.202- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.