Developer Guide

Aspose.Cells FOSS for Python is a free, open-source library for programmatic spreadsheet processing. Whether you are building data pipelines, generating automated reports, exporting ML results to Excel, or converting workbooks to Markdown for documentation pipelines, Aspose.Cells FOSS provides a comprehensive API that covers every layer of spreadsheet manipulation without requiring Microsoft Office.

Key Features

Workbook and Worksheet Operations

Create new workbooks from scratch, add worksheets, and export to XLSX or CSV. Navigate the Workbook → Worksheets → Cells → Cell hierarchy with a clean, Pythonic API. Add, rename, and remove worksheets using workbook.add_worksheet(name) and workbook.remove_worksheet(index_or_name). Access individual cells by address (ws.cells["A1"]), set values directly, and iterate over populated ranges.

Cell Styling and Formatting

Apply granular formatting to individual cells. Control font family, size, color, bold, italic, underline, and strikethrough via the Font class. Set background fills using cell.style.fill.set_solid_fill("FFRRGGBB"). Colors are expressed as 8-character AARRGGBB hex strings without a # prefix (e.g., "FFFF0000" for opaque red).

Chart Creation and Visualization

Add column, line, bar, and pie charts to worksheets using dedicated methods such as ws.charts.add_bar(top_row, left_col, bottom_row, right_col) and ws.charts.add_line(...). Set the chart title as a string (chart.title = "My Chart"), configure category data at chart level (chart.category_data = "A2:A6"), and add named series (chart.n_series.add("B2:B6", category_data="A2:A6", name="Revenue")).

Formula Support

Enter Excel-compatible formulas by setting cell.formula = "=SUM(A1:A5)" or constructing a Cell(None, "=SUM(A1:A5)") and assigning it to the cells collection.

Multi-Format Export

Export workbooks to XLSX, CSV, Markdown, and JSON using a single workbook.save(path) call. Use SaveFormat constants for explicit control: SaveFormat.XLSX, SaveFormat.CSV, SaveFormat.MARKDOWN, SaveFormat.JSON. Use MarkdownSaveOptions for fine-grained Markdown output (alignment, header level, worksheet index). Use MarkdownHandler.save_markdown_to_string(wb) for in-memory Markdown generation. See Export Format Examples for ready-to-use code and Export Troubleshooting for tips and FAQ.

Note: The FOSS library covers spreadsheet and markup formats. Advanced rendering and document conversion features are available in the commercial edition.

Plugin Ecosystem

The optional markitdown-aspose-cells-plugin package integrates with Microsoft’s MarkItDown library. Install it to add spreadsheet reading support via the MarkItDown API. Install it with pip install markitdown-aspose-cells-plugin and use it transparently via the MarkItDown API.


Getting Started

Install

Install the package from PyPI using pip before importing any aspose.cells_foss classes in your Python scripts:

pip install aspose-cells-foss

Hello World

Create a Workbook, set a cell value, and call workbook.save() to write an XLSX file:

from aspose.cells_foss import Workbook, Cell

workbook = Workbook()
ws = workbook.worksheets[0]
ws.cells["A1"].value = "Hello, Aspose.Cells FOSS!"
ws.cells["A2"].value = 42
workbook.save("hello.xlsx")

Export to Markdown

Call workbook.save_as_markdown() with an output path to export the first worksheet as a Markdown table:

from aspose.cells_foss import Workbook, Cell

workbook = Workbook()
ws = workbook.worksheets[0]
ws.cells["A1"].value = "Name"
ws.cells["B1"].value = "Score"
ws.cells["A2"].value = "Alice"
ws.cells["B2"].value = 95
ws.cells["A3"].value = "Bob"
ws.cells["B3"].value = 88

workbook.save_as_markdown("results.md")

Create a Column Chart

Write data into worksheet cells, call ws.charts.add_bar() with the chart placement bounds, configure the title and category range, and save the workbook:

from aspose.cells_foss import Workbook, Cell

workbook = Workbook()
ws = workbook.worksheets[0]

data = [("Q1", 50), ("Q2", 100), ("Q3", 170), ("Q4", 300)]
for i, (label, value) in enumerate(data):
    ws.cells[f"A{i+2}"].value = label
    ws.cells[f"B{i+2}"].value = value

chart = ws.charts.add_bar(6, 0, 20, 8)
chart.title = "Quarterly Revenue"
chart.category_data = "A2:A5"
chart.n_series.add("B2:B5", category_data="A2:A5", name="Revenue")

workbook.save("chart.xlsx")

Style Cells

Set font properties (bold, size, color) and fill the cell background by modifying cell.style.font and cell.style.fill before saving:

from aspose.cells_foss import Workbook, Cell, Font

workbook = Workbook()
ws = workbook.worksheets[0]
ws.cells["A1"] = Cell("Revenue Report")

cell = ws.cells["A1"]
cell.style.font.bold = True
cell.style.font.size = 14
cell.style.font.color = "FFFFFFFF"   # White text (AARRGGBB, no #)
cell.style.fill.set_solid_fill("FF1E64C8")  # Blue background

workbook.save("styled.xlsx")

Available Guides


See Also

 English