
In this article you will learn how to add Excel automation to Android apps. You’ll be able to create Excel XLSX or XLS files from scratch in Android programmatically. The guide also covers updating existing files, generating charts, applying formulas, and adding pivot tables.
- Android API to Create Excel File
- Create Excel XLSX or XLS Files
- Edit Existing Excel Files
- Create Charts in Excel Files
- Create a Pivot Table in an XLSX
- Add Formulas for Cells in XLSX
Android API to Create Excel File - Free Download
Aspose.Cells for Android via Java is a powerful spreadsheet API that lets you create or modify Excel files without MS Office. It supports charts, graphs, formulas, and other spreadsheet operations programmatically. Download the API or install it via Gradle:
maven {
url "https://repository.aspose.com/repo/" }
compile (
group: 'com.aspose',
name: 'aspose-cells',
version: '21.3',
classifier: 'android.via.java')
Create Excel XLSX or XLS in Android
An Excel workbook contains worksheets, each with rows and columns of cells. Follow these steps to create an XLSX file from scratch.
- Create an instance of Workbook class.
- Access the desired worksheet using Workbook.getWorksheets.get() method.
- Put the value in the desired cell using its identifier (e.g., A1, B3).
- Save the workbook as an Excel file using the Workbook.save() method.
The following code sample shows how to create an Excel XLSX file in Android.

Edit an Excel XLSX File in Android
Now see how to modify or insert data into an existing Excel file. Load the file, access the worksheet, and save the changes.
- Open Excel file using Workbook class.
- Access worksheets and cells with Worksheet and Cell classes.
- Save the updated workbook as an .xlsx file.
The following code sample shows how to edit an existing MS Excel file in Android.
Create Charts or Graphs in Excel in Android
Charts visualize worksheet data, making analysis easier. Aspose.Cells for Android via Java offers a wide range of charts you can create programmatically. Follow these steps to add a chart.
- Create a new Excel file or load an existing one using Workbook class.
- Add data to the worksheet (optional).
- Get the chart collection with Worksheet.getCharts() method.
- Add a new chart using Worksheet.getCharts().add().
- Retrieve the newly created chart from the collection.
- Define the cell range for the chart’s NSeries.
- Save the workbook as an .xlsx file.
The following code sample shows how to create a chart in Excel XLSX in Android.

Create a Pivot Table in Excel XLSX in Android
Pivot tables summarize and filter worksheet data. Create a pivot table by defining a cell range. Follow these steps.
- Create a new Workbook or load an existing file.
- Insert data into the worksheet (optional).
- Access the pivot table collection with Worksheet.getPivotTables() method.
- Add a new pivot table using Worksheet.getPivotTables().add().
- Provide data to the pivot table.
- Save the workbook.
The following code sample shows how to create a pivot table in Excel.

Add Formulas for Cells in Excel File
Aspose.Cells for Android via Java also allows you to work with formulas in Excel worksheets. You can apply built‑in as well as add‑in functions to cells.
Apply Built-in Functions in Excel
Access the desired cell and set a formula with the Cell.setFormula(String) method. The code sample below demonstrates a built‑in formula.
Add Add-in Functions in Excel
When you need a user‑defined function, register the add‑in using a .xlam file and then apply it to cells. Use registerAddInFunction(int, String) or registerAddInFunction(String, String, boolean) to register the function. The sample below shows registration and usage.
Conclusion
You have learned how to create Excel files in Android without MS Office, update workbooks, add charts, create pivot tables, and apply formulas. Explore more in the documentation or ask questions on our forum.