Skip to content

Commit 06a2778

Browse files
author
=
committed
Modified Readme
1 parent f9447b3 commit 06a2778

1 file changed

Lines changed: 169 additions & 5 deletions

File tree

README.md

Lines changed: 169 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,176 @@ A simplified way of creating a simple Excel Sheets in Android project. It is sim
77

88
---
99
The library is written in Java and using [Apache poi](http://poi.apache.org/index.html)
10+
<br><br>
11+
### **How to use in your android project**
12+
- #### **1. Add gradle dependency**
13+
---
1014

15+
-In your application `build.gradle` (app module) add this
16+
```java
17+
dependencies{
18+
.....................................
19+
..........................................
1120

12-
<br><br>
13-
### **How to use in your android**
14-
In your application `build.gradle` (app module) add this
21+
implementation 'com.github.elirehema:worksheet:0.0.1'
22+
```
23+
If you are using gradle below version 0.8.0 make sure you have added maven repository in your `project build.gradle` file
24+
```java
25+
buildscript {
26+
repositories {
27+
maven {
28+
url 'repo1.maven.org/maven2';
29+
}
30+
}
31+
...............
32+
........................
33+
}
34+
35+
repositories {
36+
mavenCentral()
37+
}
38+
39+
```
40+
>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](https://stackoverflow.com/a/26630422/7098524)
41+
42+
- #### **2. Data type's**
43+
---
44+
Worksheet version 0.0.1 support two data types
45+
46+
1. ##### **List of Objects**
47+
E.g `List<Book>` for creating an Excel Book with single Sheet.
48+
![Single excel Sheet](https://raw.githubusercontent.com/elirehema/arcolis/master/img/single_sheet.png)
49+
50+
2. ##### **List of Map of String to List of Objects **
51+
E.g `List<Map<String, List<Books>>>` fo creating an Excel Book with multiple Excel Sheet.
52+
![Multiple excel sheets](https://raw.githubusercontent.com/elirehema/arcolis/master/img/Screenshot%20from%202020-08-24%2020-00-18.png)
53+
54+
55+
56+
- #### **3. Populate Excel Sheet with data**
57+
---
58+
In your Activity class create an instance of WorkSheet class
59+
```java
60+
public class MainActivity extends AppCompatActivity {
61+
private WorkSheet workSheet;
62+
private Button button;
63+
........
64+
...................
65+
protected void onCreate(Bundle savedInstanceState) {
66+
super.onCreate(savedInstanceState);
67+
setContentView(R.layout.activity_main);
68+
69+
button = findViewById(R.id.create_excel_sheet);
70+
final String path = "ExternalFilePath";
71+
72+
button.setOnClickListener(new View.OnClickListener() {
73+
@Override
74+
public void onClick(View view) {
75+
try {
76+
workSheet = new WorkSheet.Builder(getApplicationContext(), path)
77+
.setSheet(List<Object>)
78+
.writeSheet();
79+
} catch (IOException e) {
80+
e.printStackTrace();
81+
}
82+
}
83+
});
84+
85+
86+
}
87+
}
88+
89+
```
90+
The instance accept to variables application context and extenalFilePath as the name of the file.
91+
92+
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.
93+
94+
<br>
95+
96+
- #### **IMPORTANT NOTE**
97+
---
98+
The `WorkSheet.Builder(getApplicationContext(), path)` have two chirld methods for accepting either ``List<Object>`` or `List<Map<String, List<Object>>>`.
99+
100+
- To create Excel book with multiple Single Sheet use:
15101
```java
16-
implementation 'com.github.elirehema:worksheet:0.0.1'
102+
new WorkSheet.Builder(getApplicationContext(), path)
103+
.setSheet(List<Objects>)
104+
.writeSheet();
105+
```
106+
- To create an Excel book with mutliple Sheets use:
107+
108+
```java
109+
new WorkSheet.Builder(getApplicationContext(), path)
110+
.setSheets(List<Map<String, List<Object>>>)
111+
.writeSheets();
112+
```
113+
114+
- #### **4. Cell Styling**
115+
---
116+
By default cell style create an Excel sheet with black texts and borders. But you can change either title, Header and Data cell styles by using the mentioned CellEnum types.
117+
118+
| Enum Type | Source | Properties |
119+
| ---------------|:-------------------:|--------------:|
120+
| DEFAULT_HEADER | CellEnum | No Effect |
121+
| DEFAULT_TITLE | CellEnum | No Effect |
122+
| DEFAULT_CELL | CellEnum |No Effect |
123+
| TEAL_HEADER | CellEnum |Teal text, bold, white text |
124+
| TEAL_TITLE | CellEnum |Teal text, medium, white text |
125+
| TEAL_CELL | CellEnum | Teal text, normal, white text |
126+
| FORMULA_1 | CellEnum | Give it a try |
127+
| FORMULA_2 | CellEnum | Give it a try |
128+
| FORMULA_3 | CellEnum | Give it a try |
129+
| LINE_2 | CellEnum |Give it a try |
130+
| LINE_1 | CellEnum |Give it a try |
131+
132+
<br>
133+
134+
- - ##### **Using Styles**
135+
In your Builder method add `.title(CellEnum_ENUM_TYPE)` to change title cell style or `.header(CellEnum.ENUM_TYPE)` for header cells or `.cell(CellEnum.ENUM_TYPE)` for data cells
136+
137+
138+
Example 1.
139+
140+
```java
141+
new ESheet.Builder(multipleFilePath)
142+
.header(EType.TEAL_HEADER)
143+
.cell(EType.LINE_2)
144+
.title(EType.TEAL_TITLE)
145+
.setSheet(getListBook("New Sample Book"))
146+
.writeSheet();
17147
```
18-
<span style="color:blue">some *This is Blue italic.* text</span>
148+
![Teal header](https://github.com/elirehema/arcolis/blob/master/img/style_1.png?raw=true)
149+
150+
Example 2.
151+
152+
```java
153+
eSheet = new ESheet.Builder(multipleFilePath)
154+
155+
.title(EType.TEAL_HEADER)
156+
.header(EType.FORMULA_1)
157+
.cell(EType.DEFAULT_CELL)
158+
.setData(getListBook("New Sample Book"))
159+
.write();
160+
```
161+
![Teal header](https://github.com/elirehema/arcolis/blob/master/img/exmple_1.png?raw=true)
162+
163+
Example 3.
164+
```java
165+
List<Map<String, List<?>> > languageList = getListOfObject();
166+
String excelFilePath = "NiceJavaBooks";
167+
String multipleFilePath = "BookList";
168+
eSheet = new ESheet.Builder(multipleFilePath)
169+
170+
.title(EType.TEAL_HEADER)
171+
.header(EType.FORMULA_1)
172+
.cell(EType.DEFAULT_CELL)
173+
.setSheets(languageList)
174+
.writeSheets();
175+
```
176+
![Mutliple Excel Sheets](https://github.com/elirehema/arcolis/blob/master/img/ezgif.com-video-to-gif.gif?raw=true)
177+
- #### **Remember**
178+
---
179+
setSheet(List<Objects>) goes with createSheet()
180+
setSheets(List<Map<String, List<Object>>>) goes with createSheets()
181+
182+
- Repository is open for PR's, Issues, Fork, etc

0 commit comments

Comments
 (0)