Create ODS File Via Python
Generate Excel ODS Files via your Python Applications without installing Microsoft Office®.
For a developer, who is trying to create ODS files via Python application? Aspose.Total for Python via Java API can help to automate the create process. It’s a full package of various APIs dealing different formats including Microsoft Office files and Images. Aspose.Cells for Python via Java API that is part of Aspose.Total for Python via Java package makes this generation process easy. Below is the process of creation. Moreover, developers can easily enhance the application for modification of ODS file. To update ODS file using Python process is same except that it requires existing file as parameter while creating the Workbook object.
How to Create ODS File in Python
- Create new Workbook class object having FileFormatType as parameter
- Get the access of required Worksheet using getWorksheets().get(index) method
- Insert data in the accessed cell using Worksheet.getCells().get(indexValue).putValue() method
- Save the document as .ods file using save() by passing the file with path as the parameter
Creation Requirements
- For ODS generation, reference APIs within the project directly from PyPI ( Aspose.Cells )
- Or use the following pip command
pip install aspose.cells
- Moreover, Download the API package from the downloads section
Create ODS File in Python
# create a new XLSX workbook | |
workbook = Workbook(FileFormatType.XLSX) | |
worksheet = workbook.getWorksheets().get(0) | |
# Insert a string value to a cell | |
worksheet.getCells().get("C2").setValue("Image") | |
# set the 4th row height | |
worksheet.getCells().setRowHeight(3, 150) | |
# set the C column width | |
worksheet.getCells().setColumnWidth(3,50) | |
# add a picture to the D4 cell | |
index = worksheet.getPictures().add(3, 3, "aspose-cells-for-python.png") | |
# get the picture object | |
pic = worksheet.getPictures().get(index) | |
# save the Excel file | |
workbook.save("workbook_with_image.xlsx") |
Explore Options with Python
What is ODS File Format?
The OpenDocument Spreadsheet (ODS) format is specifically designed for storing spreadsheet data and is commonly used by open source office suites like Apache OpenOffice and LibreOffice. ODS files utilize the OpenDocument XML format and are identified by the .ods file extension.
In an ODS file, data can be organized and stored within cells, allowing for efficient tabular representation. Cells can be formatted using various styles to enhance the visual appearance and readability. Additionally, ODS files can incorporate charts and other graphical elements to present data in a visually appealing manner.
One notable advantage of ODS files is their smaller file size compared to similar spreadsheet formats such as Microsoft Excel’s .xlsx format. This compactness facilitates easier file sharing, as smaller files are quicker to transfer and require less storage space.
ODS files offer compatibility and interoperability across multiple office suites and spreadsheet applications. They can be opened and edited in various software programs, ensuring flexibility in working with spreadsheet data. Furthermore, many applications support exporting data to the ODS format, enabling seamless data exchange between different software platforms.
The ODS format’s open nature and widespread support make it a practical choice for sharing and collaborating on spreadsheet data, promoting data portability and facilitating efficient workflows across different software applications.