worksheet

Android dependency library for creating Simple Excel Sheets. Depends on Apache poi and Java

View the Project on GitHub

Worksheet

Android CI License Maven Central


A simplified way of creating a simple Excel Sheets in Android project. It is simple as explained below.


The library is written in Java and using Apache poi

How to use in your android project

-In your application build.gradle (app module) add this

dependencies{
              .....................................
              ..........................................

              implementation 'com.github.elirehema:worksheet:0.0.1'
          }

If you are using gradle below version 0.8.0 make sure you have added maven repository in your project build.gradle file

buildscript { 
    repositories { 
        maven { 
            url 'repo1.maven.org/maven2'; 
        } 
    } 
    ...............
    ........................
} 

repositories {
    mavenCentral()
}

As of version 0.8.9, Android Studio supports the Maven Central Repository by default. So to add an external maven dependency all you need to do is edit the module’s build.gradle file and insert a line into the dependencies section Source

  1. List of Objects

    E.g List<Book> for creating an Excel Book with single Sheet. Single excel Sheet

  2. **List of Map of String to List of Objects **

    E.g List<Map<String, List<Books>>> fo creating an Excel Book with multiple Excel Sheet. Multiple excel sheets

The instance accept to variables application context and extenalFilePath as the name of the file.

With this few steps the excel file with name provided as externalFilePath String will be save in the external directory `worksheets` created by worksheet dependency in your device. 

<br>

- #### **IMPORTANT NOTE**
---
The `WorkSheet.Builder(getApplicationContext(), path)` have two chirld methods for accepting either ``List<Object>`` or `List<Map<String, List<Object>>>`.

- To create Excel book with multiple Single Sheet use:
```java
new WorkSheet.Builder(getApplicationContext(), path)
                            .setSheet(List<Objects>)
                            .writeSheet();
new WorkSheet.Builder(getApplicationContext(), path)
                            .setSheets(List<Map<String, List<Object>>>)
                            .writeSheets();
Enum Type Source Properties
DEFAULT_HEADER CellEnum No Effect
DEFAULT_TITLE CellEnum No Effect
DEFAULT_CELL CellEnum No Effect
TEAL_HEADER CellEnum Teal text, bold, white text
TEAL_TITLE CellEnum Teal text, medium, white text
TEAL_CELL CellEnum Teal text, normal, white text
FORMULA_1 CellEnum Give it a try
FORMULA_2 CellEnum Give it a try
FORMULA_3 CellEnum Give it a try
LINE_2 CellEnum Give it a try
LINE_1 CellEnum Give it a try


Example 1.

 new ESheet.Builder(multipleFilePath)
                .header(EType.TEAL_HEADER)
                .cell(EType.LINE_2)
                .title(EType.TEAL_TITLE)
                .setSheet(getListBook("New Sample Book"))
                .writeSheet();

Teal header

Example 2.

 eSheet = new ESheet.Builder(multipleFilePath)

                .title(EType.TEAL_HEADER)
                .header(EType.FORMULA_1)
                .cell(EType.DEFAULT_CELL)
                .setData(getListBook("New Sample Book"))
                .write();

Teal header

Example 3.

   List<Map<String, List<?>> > languageList = getListOfObject();
        String excelFilePath = "NiceJavaBooks";
        String multipleFilePath = "BookList";
        eSheet = new ESheet.Builder(multipleFilePath)

                .title(EType.TEAL_HEADER)
                .header(EType.FORMULA_1)
                .cell(EType.DEFAULT_CELL)
                .setSheets(languageList)
                .writeSheets();

Mutliple Excel Sheets