How To Open XLSX Files on an Android Device

Introduced as part of Microsoft Office 2007, XLSX is a file format used in Microsoft Excel 2007 and later versions. It’s XML-based, and is currently the default format for Excel documents. The format is also compatible with several other spreadsheet software, including Google Sheets.

How To Open XLSX Files on an Android Device

Though it’s most likely that you’ll edit your XLSX files on a desktop, you may need to make on-the-fly edits using your Android device. For example, you may have a client file that you wish to update when meeting with the customer. Happily, it’s possible to open and edit XLSX files using Android. In this article, we examine how to do that in several ways.

How to Open XLSX File on an Android

All Android devices are essentially handheld computers that use touchscreens, meaning it’s possible to use them to complete many of the tasks you’d typically use a desktop computer for. Opening and editing XLSX files are some of those tasks, assuming you have Google Sheets or Microsoft Excel on your device.

Google Sheets

  1. Download Google Sheets from the Play Store and open it.
  2. Sign in to your Google Account if you’re not already signed in.
  3. Transfer your XLSX file to your phone’s internal storage. You can do this by emailing the file to yourself or downloading it from an appropriate channel, such as Slack.
  4. Navigate to Google Files on your device.
  5. Select “Documents & other.”
  6. Tap the XLSX file and select “Open in Google Sheets.”
  7. Select “Allow” when Google Sheets asks if it can access the media and photos stored on your device.

The XLSX file should now be open on your phone, allowing you to make basic adjustments. With Google Sheets installed, you can also open XLSX files from Google Drive, assuming you’ve saved the file in Google Drive. Simply sign in to your Drive account, tap the file, and it opens in Google Sheets. Note that you need to enable editing permissions for your Google account to edit Google Drive files.

Microsoft Excel

Some Android phones come with Microsoft Office preinstalled. Assuming you have a license to use Office, you have access to Excel automatically. If that’s the case, skip this section.

  1. Download Microsoft Excel or Microsoft Office from the Google Play store. Both provide access to Excel.
  2. Tap “Install” when the download finishes.
  3. Navigate to the Excel icon and tap it to open the software.
  4. Select “ALLOW” when Excel asks if it can access your device’s photos, media, and files.
  5. Tap “Get Started.”
  6. Select “Next.”
  7. Choose whether to send optional data to Microsoft and its partners.
  8. Tap “CLOSE.”

You now have Microsoft Excel installed on your Android device. Now, it’s time to open an XLSX file.

  1. Open Excel or Microsoft Office.
  2. Click the folder icon.
  3. Select the storage medium for your file. You can choose between OneDrive, your device, Google Drive, an SD card, or somewhere else.
  4. Choose the XLSX file to open it.

How To Open XLSX Files on a Samsung Phone

Samsung phones all have the Android operating system installed as standard. This means the steps for opening XLSX files using Google Sheets and Microsoft Office cross over.

Google Sheets

  1. Go to the Play Store and download Google Sheets.
  2. Tap “Install.”
  3. Sign in to your Google Account.
  4. Move your XLSX file to your phone’s internal storage.
  5. Locate Google Files on your Samsung device.
  6. Tap “Documents & other.”
  7. Select your file and choose “Open in Google Sheets/ Office 365.”
  8. Allow Google Sheets to access your phone’s internal media.

Microsoft Office

Your Samsung phone may also have Microsoft Office installed. If it does, you can use Office to open XLSX files, assuming you have a valid license for the software suite.

  1. Tap the Microsoft Office icon.
  2. Select the folder icon.
  3. Choose the location where the XLSX file is stored.
  4. Tap the file to open it in the mobile version of Microsoft Excel.

How to Open XLSX Files in Android Programmatically

You can open XLSX files programmatically using the Apache POI API. This is a pure Java API that allows you to read and write Excel files. The following steps come from CodeJava and were created by Nam Ha Minh.

Step No. 1 – Get the Apache POI Library

Head to the Apache POI page and download the most recent stable version of the API. Extract the zip file you downloaded and add the following JAR files to your project’s classpath:

  • poi-VERSION.jar
  • poi-ooxml-VERSION.jar
  • poi-ooxml-schemas-VERSION.jar
  • xmlbeans-VERSION.jar

Step No. 2 – Create an XLSX File

Using Microsoft Excel 2007 or later, create an XLSX file that you will read with your code. Nam Ha Minh provides the following example, which is relevant to the code shared below.

ABCD
   
 Head First JavaKathy Serria79
 Effective JavaJoshua Bloch36
 Clean CodeRobert Martin42
 Thinking in JavaBruce Eckel35

You can adjust these data entries as needed.

Step No. 3 – Create a Model Class

Use the following code to create a model class.

1
2
3 
4 
5 package net.codejava.excel;
6 public class Book {
7 private String title;
8 private String author;
9 private float price;
10 public Book() {
11 }
12 public String toString() {
13  return String.format("%s - %s - %f", title, author, price);
14 }
15 // getters and setters
16 }

Name the model class Book.java.

Step No. 4 – Create a Method to Read the Value of a Cell

The following code allows your Android device to read the value of a single cell:

1
2
3
4 private Object getCellValue(Cell cell) {
5 switch (cell.getCellType()) {
6 case Cell.CELL_TYPE_STRING:
7  return cell.getStringCellValue();
8 case Cell.CELL_TYPE_BOOLEAN:
9  return cell.getBooleanCellValue();
10 case Cell.CELL_TYPE_NUMERIC:
11  return cell.getNumericCellValue();
12 }
13 return null;
14 }

Step No. 5 – Create a Method to Read the XLSX File and Return a List

The following code allows you to generate a list using your XLSX file.

1
2
3
4
5
6
7
8
9 public List<Book> readBooksFromExcelFile(String excelFilePath) throws IOException {
10 List<Book> listBooks = new ArrayList<>();
11 FileInputStream inputStream = new FileInputStream(new File(excelFilePath));
12 Workbook workbook = new XSSFWorkbook(inputStream);
13 Sheet firstSheet = workbook.getSheetAt(0);
14 Iterator<Row> iterator = firstSheet.iterator();
15 while (iterator.hasNext()) {
16  Row nextRow = iterator.next();
17  Iterator<Cell> cellIterator = nextRow.cellIterator();
18  Book aBook = new Book();
19  while (cellIterator.hasNext()) {
20   Cell nextCell = cellIterator.next();
21   int columnIndex = nextCell.getColumnIndex();
22   switch (columnIndex) {
23   case 1:
24    aBook.setTitle((String) getCellValue(nextCell));
25    break;
26   case 2:
27    aBook.setAuthor((String) getCellValue(nextCell));
28    break;
29   case 3:
30    aBook.setPrice((double) getCellValue(nextCell));
31    break;
32   }
33  }
34  listBooks.add(aBook);
35 }
36 workbook.close();
37 inputStream.close();
38 return listBooks;
39 }

Step No. 6 – Test the Output

Use the following code to test the program’s output.

1 public static void main(String[] args) throws IOException {
2 String excelFilePath = "Books.xlsx";
3 ExcelReaderExample2 reader = new ExcelReaderExample2();
4 List<Book> listBooks = reader.readBooksFromExcelFile(excelFilePath);
5 System.out.println(listBooks);
6 }

You should find that the code outputs a simple list containing all four rows, one after the other, with a comma between each entry.

It’s also worth noting that this is one of many ways to open XLSX files on an Android device programmatically. Other methods exist that use different APIs or code. This example simply proves that it’s possible.

Access XLSX Files the Easy or Hard Way

Using the programmatic method to access XLSX files is possible, though it’s also long-winded. Both Google Sheets and Microsoft Excel for mobile provide better readouts and a much simpler way to access XLSX files. In the case of Google Sheets, you also don’t have to pay for a software license to open your files.

Now, we want to hear from you. Why do you want to open an XLSX file on your Android or Samsung device? Are you likely to use a programmatical method when simpler methods exist? Tell us in the comments section below.

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.