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 enprojectnment-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---56# LibreOffice Calc78## Overview910LibreOffice Calc skill for creating, editing, converting, and automating spreadsheet workflows using the native ODS (OpenDocument Spreadsheet) format.1112## When to Use This Skill1314Use this skill when:15- Creating new spreadsheets in ODS format16- Converting between ODS, XLSX, CSV, PDF formats17- Automating data processing and analysis18- Creating formulas, charts, and pivot tables19- Batch processing spreadsheet operations2021## Core Capabilities2223### 1. Spreadsheet Creation24- Create new ODS spreadsheets from scratch25- Generate spreadsheets from templates26- Create data entry forms27- Build dashboards and reports2829### 2. Format Conversion30- ODS to other formats: XLSX, CSV, PDF, HTML31- Other formats to ODS: XLSX, XLS, CSV, DBF32- Batch conversion of multiple files3334### 3. Data Automation35- Formula automation and calculations36- Data import from CSV, database, APIs37- Data export to various formats38- Batch data processing3940### 4. Data Analysis41- Pivot tables and data summarization42- Statistical functions and analysis43- Data validation and filtering44- Conditional formatting4546### 5. Integration47- Command-line automation via soffice48- Python scripting with UNO49- Database connectivity5051## Workflows5253### Creating a New Spreadsheet5455#### Method 1: Command-Line56```bash57soffice --calc template.ods58```5960#### Method 2: Python with UNO61```python62import uno6364def create_spreadsheet():65 local_ctx = uno.getComponentContext()66 resolver = local_ctx.ServiceManager.createInstanceWithContext(67 "com.sun.star.bridge.UnoUrlResolver", local_ctx68 )69 ctx = resolver.resolve(70 "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"71 )72 smgr = ctx.ServiceManager73 doc = smgr.createInstanceWithContext("com.sun.star.sheet.SpreadsheetDocument", ctx)74 sheets = doc.getSheets()75 sheet = sheets.getByIndex(0)76 cell = sheet.getCellByPosition(0, 0)77 cell.setString("Hello from LibreOffice Calc!")78 doc.storeToURL("file:///path/to/spreadsheet.ods", ())79 doc.close(True)80```8182#### Method 3: Using ezodf83```python84import ezodf8586doc = ezodf.newdoc('ods', 'spreadsheet.ods')87sheet = doc.sheets[0]88sheet['A1'].set_value('Hello')89sheet['B1'].set_value('World')90doc.save()91```9293### Converting Spreadsheets9495```bash96# ODS to XLSX97soffice --headless --convert-to xlsx spreadsheet.ods9899# ODS to CSV100soffice --headless --convert-to csv spreadsheet.ods101102# ODS to PDF103soffice --headless --convert-to pdf spreadsheet.ods104105# XLSX to ODS106soffice --headless --convert-to ods spreadsheet.xlsx107108# Batch convert109for file in *.ods; do110 soffice --headless --convert-to xlsx "$file"111done112```113114### Formula Automation115```python116import uno117118def create_formula_spreadsheet():119 local_ctx = uno.getComponentContext()120 resolver = local_ctx.ServiceManager.createInstanceWithContext(121 "com.sun.star.bridge.UnoUrlResolver", local_ctx122 )123 ctx = resolver.resolve(124 "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"125 )126 smgr = ctx.ServiceManager127 doc = smgr.createInstanceWithContext("com.sun.star.sheet.SpreadsheetDocument", ctx)128 sheet = doc.getSheets().getByIndex(0)129 130 sheet.getCellByPosition(0, 0).setDoubleValue(100)131 sheet.getCellByPosition(0, 1).setDoubleValue(200)132 133 cell = sheet.getCellByPosition(0, 2)134 cell.setFormula("SUM(A1:A2)")135 136 doc.storeToURL("file:///path/to/formulas.ods", ())137 doc.close(True)138```139140## Format Conversion Reference141142### Supported Input Formats143- ODS (native), XLSX, XLS, CSV, DBF, HTML144145### Supported Output Formats146- ODS, XLSX, XLS, CSV, PDF, HTML147148## Command-Line Reference149150```bash151soffice --headless152soffice --headless --convert-to <format> <file>153soffice --calc # Calc154```155156## Python Libraries157158```bash159pip install ezodf # ODS handling160pip install odfpy # ODF manipulation161pip install pandas # Data analysis162```163164## Best Practices1651661. Use named ranges for clarity1672. Document complex formulas1683. Use data validation for input control1694. Create templates for recurring reports1705. Store ODS source files in version control1716. Test conversions thoroughly1727. Use CSV for data exchange1738. Handle conversion failures gracefully174175## Troubleshooting176177### Cannot open socket178```bash179killall soffice.bin180soffice --headless --accept="socket,host=localhost,port=8100;urp;"181```182183## Resources184185- [LibreOffice Calc Guide](https://documentation.libreoffice.org/)186- [UNO API Reference](https://api.libreoffice.org/)187- [ezodf Documentation](http://ezodf.rst2.org/)188189## Related Skills190191- writer192- impress193- draw194- base195- xlsx-official196- workflow-automation197198## Limitations199- Use this skill only when the task clearly matches the scope described above.200- Do not treat the output as a substitute for enprojectnment-specific validation, testing, or expert review.201- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.