Your First Aspose.Cells Application - Hello World

Creating the Hello World Application

To create the Hello World application using Aspose.Cells API:

  1. Create an instance of the Workbook class.
  2. Apply the license:
    1. If you have purchased a license, then use the license in your application to get access to Aspose.Cells' full functionality
    2. If you are using the evaluation version of the component (if you’re using Aspose.Cells without a license), skip this step.
  3. Create a new Microsoft Excel file, or open an existing file in which you want to add/update some text.
  4. Access any cell of a worksheet in the Microsoft Excel file.
  5. Insert the words Hello World! into a cell accessed.
  6. Generate the modified Microsoft Excel file.

The examples below demonstrate the above steps.

Creating a Workbook

The following example creates a new workbook from scratch, writes the words “Hello World!” into cell A1 on the first worksheet, and saves the file.

The generated spreadsheet

todo:image_alt_text

import aspose.cells
from aspose.cells import Workbook
# Create an instance of the Workbook class.
workbook = Workbook()
# Insert the words Hello World! into a cell accessed.
workbook.worksheets.get(0).cells.get("A1").put_value("Hello World")
# Save as XLS file
workbook.save("output.xls")
# Save as XLSX file
workbook.save("output.xlsx")
# Save as ods file
workbook.save("output.ods")

Opening an Existing File

The following example opens an existing Microsoft Excel template file called book1.xls, writes the words “Hello World!” in cell A1 in the first worksheet, and saves the workbook as a new file.

import aspose.cells
from aspose.cells import Workbook
# Open an existing file
workbook = Workbook("Input.xlsx")
# Set cell value
workbook.worksheets.get(0).cells.get("A1").put_value("Aspose Cells")
# Save as XLS
workbook.save("output.xls")
# Save as XLSX
workbook.save("output.xlsx")
# Save as ODS
workbook.save("output.ods")