Skip to content

Commit c094975

Browse files
committed
[v3.x.x]: updated the README; change the version from 3.2.0-SNAPSHOT to 3.2.0
1 parent d38fcf0 commit c094975

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

README.md

+41-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
# poi-object-mapper
77

8-
**poi-object-mapper** is a wrapper java library for [Apache POI](https://poi.apache.org/) (Apache POI provides java API to read Microsoft Office Formats). POI APIs are very low level giving acess to all the internals of the file formats.
8+
**poi-object-mapper** is a wrapper java library for [Apache POI](https://poi.apache.org/) (Apache POI provides java API to read Microsoft Office Formats). POI APIs are very low level giving access to all the internals of the file formats.
99

10-
The aim of this project is to provide easy to use highlevel APIs to read the Office file formats by wrapping the POI APIs. In simple terms, the wrapper APIs would look similar to the [Jackson Project for XML and JSON](https://github.com/FasterXML/jackson), where the data can be mapped to a JAVA Bean and through the mapper APIs, the file data can directly be read as java objects.
10+
The aim of this project is to provide easy to use high-level APIs to read the Office file formats by wrapping the POI APIs. In simple terms, the wrapper APIs would look similar to the [Jackson Project for XML and JSON](https://github.com/FasterXML/jackson), where the data can be mapped to a JAVA Bean and through the mapper APIs, the file data can directly be read as java objects.
1111

1212
*- Note that the current version of the library supports only **spreadsheets** (Excel files).*
1313

@@ -22,7 +22,7 @@ This library is available in [Maven Central](https://mvnrepository.com/artifact/
2222
<dependency>
2323
<groupId>io.github.millij</groupId>
2424
<artifactId>poi-object-mapper</artifactId>
25-
<version>3.1.0</version>
25+
<version>3.2.0</version>
2626
</dependency>
2727
```
2828

@@ -95,7 +95,7 @@ Reading spreadsheet rows as `Map<String, Object>` Objects ..
9595
```
9696

9797

98-
##### Writing a collection of objects to file
98+
##### Writing a List of objects to file
9999

100100
Similar to `Reader`, the mapped Java Beans can be written to files.
101101

@@ -116,7 +116,43 @@ Use `XlsWriter` for `.xls` files and `XlsxWriter` for `.xlsx` files.
116116
...
117117
```
118118

119-
## Implementation Details
119+
##### Writing a List of objects defined as Map to file
120+
121+
Similar to `Reader`, the `Writer` also supports Row data defined as `Map<String, Object>`.
122+
This is to support the data that is not backed by a concrete bean Class definition
123+
124+
Use `XlsWriter` for `.xls` files and `XlsxWriter` for `.xlsx` files.
125+
126+
```java
127+
...
128+
// Employees
129+
final Map<String, Object> emp1 = new HashMap<>();
130+
emp1.put("Name", "foo");
131+
emp1.put("Age", 12);
132+
emp1.put("Gender", "MALE");
133+
emp1.put("Height (mts)", 1.68);
134+
135+
final Map<String, Object> emp2 = new HashMap<>();
136+
emp1.put("Name", "bar");
137+
emp1.put("Age", null);
138+
emp1.put("Gender", "MALE");
139+
140+
final List<Map<String, Object>> employees = Arrays.asList(emp1, emp2);
141+
142+
// Headers (or Column Names)
143+
final List<String> headers = new ArrayList<>();
144+
headers.add("Name");
145+
headers.add("Age");
146+
headers.add("Gender");
147+
headers.add("Height (mts)");
148+
headers.add("Address");
149+
150+
// Writer
151+
final SpreadsheetWriter writer = new XlsxWriter();
152+
writer.addSheet(employees, headers);
153+
writer.write("<output_file_path>");
154+
155+
```
120156

121157

122158

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ repositories {
1111
}
1212

1313

14-
sourceCompatibility = 1.11
15-
targetCompatibility = 1.11
14+
sourceCompatibility = 1.8
15+
targetCompatibility = 1.8
1616

1717
group = 'io.github.millij'
18-
version = '3.2.0-SNAPSHOT'
18+
version = '3.2.0'
1919

2020

2121
dependencies {

0 commit comments

Comments
 (0)