
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
aspose-cells-python
Advanced tools
Aspose.Cells for Python via .NET is a high-performance library that unleashes the full potential of Excel in your Python projects. It can be used to efficiently manipulate and convert Excel and spreadsheet formats including XLS, XLSX, XLSB, ODS, CSV, and HTML - all from your Python code. Amazingly, it also offers free support.
Product Page <https://products.aspose.com/cells/python-net>_ | Docs <https://docs.aspose.com/cells/python-net/>_ | API Reference <https://reference.aspose.com/cells/python-net/>_ | Demos <https://products.aspose.app/cells/family/>_ | Blog <https://blog.aspose.com/category/cells/>_ | Code Samples <https://github.com/aspose-cells/Aspose.Cells-for-Python-via-.NET>_ | Free Support <https://forum.aspose.com/c/cells>_ | Temporary License <https://purchase.aspose.com/temporary-license>_ | EULA <https://company.aspose.com/legal/eula>_
Try our free online apps <https://products.aspose.app/cells/family>_ demonstrating some of the most popular Aspose.Cells functionality.
Aspose.Cells for Python via .NET is a powerful spreadsheet management library that allows developers to create, format, and manipulate Excel files programmatically without the need for Microsoft Excel. It supports features like:
Create Excel file from scratch
.. code-block:: python
# import the python package
import aspose.cells
from aspose.cells import License, Workbook, FileFormatType
# Instantiating a Workbook object
workbook = Workbook()
# Get the first worksheet
worksheet = workbook.worksheets[0]
# Get the "A1" cell
cell = worksheet.cells.get("A1")
# Write "Hello World" to "A1" in the first sheet
cell.put_value("Hello World!")
# Saving this workbook to XLSX
workbook.save("HelloWorld.xlsx")
Convert Excel XLSX file to PDF
.. code-block:: python
# import the python package
import aspose.cells
from aspose.cells import Workbook
# Instantiating a Workbook object
workbook = Workbook("HelloWorld.xlsx")
# Saving this workbook to PDF
workbook.save("HelloWorld.pdf")
Create a chart
.. code-block:: python
from aspose.cells import Workbook
from aspose.cells.charts import ChartType
# Instantiating a Workbook object
workbook = Workbook()
# Adding a new worksheet to the Excel object
sheetIndex = workbook.worksheets.add()
# Obtaining the reference of the newly added worksheet by passing its sheet index
worksheet = workbook.worksheets[sheetIndex]
# Adding sample values to cells
worksheet.cells.get("A1").put_value(50)
worksheet.cells.get("A2").put_value(100)
worksheet.cells.get("A3").put_value(170)
worksheet.cells.get("A4").put_value(300)
worksheet.cells.get("B1").put_value(160)
worksheet.cells.get("B2").put_value(32)
worksheet.cells.get("B3").put_value(50)
worksheet.cells.get("B4").put_value(40)
# Adding sample values to cells as category data
worksheet.cells.get("C1").put_value("Q1")
worksheet.cells.get("C2").put_value("Q2")
worksheet.cells.get("C3").put_value("Y1")
worksheet.cells.get("C4").put_value("Y2")
# Adding a chart to the worksheet
chartIndex = worksheet.charts.add(ChartType.COLUMN, 5, 0, 15, 5)
# Accessing the instance of the newly added chart
chart = worksheet.charts[chartIndex]
# Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B4"
chart.n_series.add("A1:B4", True)
# Setting the data source for the category data of SeriesCollection
chart.n_series.category_data = "C1:C4"
# Saving the Excel file
workbook.save("Chart.xlsx")
Convert Excel workbook to JSON
.. code-block:: python
from aspose.cells import Workbook
# Instantiating a Workbook object
workbook = Workbook()
# Obtaining the reference of the newly added worksheet
sheet = workbook.worksheets[0]
cells = sheet.cells
# Setting the value to the cells
cells.get("A1").put_value("First name")
cells.get("A2").put_value("Simon")
cells.get("A3").put_value("Kevin")
cells.get("A4").put_value("Leo")
cells.get("A5").put_value("Johnson")
cells.get("B1").put_value("Age")
cells.get("B2").put_value(32)
cells.get("B3").put_value(33)
cells.get("B4").put_value(34)
cells.get("B5").put_value(35)
cells.get("C1").put_value("Value")
cells.get("C2").put_value(123.546)
cells.get("C3").put_value(56.78)
cells.get("C4").put_value(34)
cells.get("C5").put_value(9)
# Saving the Excel file to json
workbook.save("Out.json")
Convert Excel to Pandas DataFrame
.. code-block:: python
import pandas as pd
from aspose.cells import Workbook
# Create a new Aspose.Cells Workbook
workbook = Workbook()
# Get the first worksheet
worksheet = workbook.worksheets[0]
# Get the cells
cells = worksheet.cells
# Add header and data values to specific cells
cells.get("A1").value = "Name"
cells.get("B1").value = "Age"
cells.get("C1").value = "City"
cells.get("A2").value = "Alice"
cells.get("B2").value = 25
cells.get("C2").value = "New York"
cells.get("A3").value = "Bob"
cells.get("B3").value = 30
cells.get("C3").value = "San Francisco"
cells.get("A4").value = "Charlie"
cells.get("B4").value = 35
cells.get("C4").value = "Los Angeles"
rowCount = cells.max_data_row
columnCount = cells.max_data_column
# Read the header row (row 0) and store column names
columnDatas = []
for c in range(columnCount + 1):
columnDatas.append(cells.get_cell(0, c).value)
# Create an empty pandas DataFrame with column names from Excel
result = pd.DataFrame(columns=columnDatas, dtype=object)
# Read each data row (from row 1 onward) and add to the DataFrame
for i in range(1, rowCount + 1):
rowarray = [cells.get_cell(i, j).value for j in range(columnCount + 1)]
result.loc[i - 1] = rowarray
print(result)
Combine two workbooks into one
.. code-block:: python
from aspose.cells import Workbook
# Load the first Workbook
SourceBook1 = Workbook("first.xlsx")
# Load the second Workbook
SourceBook2 = Workbook("second.xlsx")
# Combine the second workbook into the first workbook
SourceBook1.combine(SourceBook2)
# Save the combined workbook to a new file
SourceBook1.save("combined.xlsx")
Product Page <https://products.aspose.com/cells/python-net>_ | Docs <https://docs.aspose.com/cells/python-net/>_ | API Reference <https://reference.aspose.com/cells/python-net/>_ | Demos <https://products.aspose.app/cells/family/>_ | Blog <https://blog.aspose.com/category/cells/>_ | Free Support <https://forum.aspose.com/c/cells>_ | Temporary License <https://purchase.aspose.com/temporary-license>_ | EULA <https://company.aspose.com/legal/eula>_
FAQs
Aspose.Cells for Python via .NET is a high-performance library that unleashes the full potential of Excel in your Python projects. It can be used to efficiently manipulate and convert Excel and spreadsheet formats including XLS, XLSX, XLSB, ODS, CSV, and HTML - all from your Python code. Amazingly, it also offers free support.
We found that aspose-cells-python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.