Skip to content

Commit 16fe124

Browse files
committed
Merge branch 'v1.x.x'
2 parents 8185326 + fb967b0 commit 16fe124

File tree

3 files changed

+167
-22
lines changed

3 files changed

+167
-22
lines changed

README.md

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
[![Build Status](https://travis-ci.org/millij/poi-object-mapper.svg?branch=master)](https://travis-ci.org/millij/poi-object-mapper)
23
[![codecov](https://codecov.io/gh/millij/poi-object-mapper/branch/master/graph/badge.svg)](https://codecov.io/gh/millij/poi-object-mapper)
34

@@ -13,7 +14,19 @@ The aim of this project is to provide easy to use highlevel APIs to read the Off
1314

1415
## Include
1516

16-
This library is not yet available in the Maven Central. For now it hast to be installed manually. Please check the [releases](https://github.com/millij/poi-object-mapper/releases) page for change log and versions.
17+
This library is available in [Maven Central](https://mvnrepository.com/artifact/io.github.millij/poi-object-mapper).
18+
19+
`pom.xml` entry details..
20+
21+
```
22+
<dependency>
23+
<groupId>io.github.millij</groupId>
24+
<artifactId>poi-object-mapper</artifactId>
25+
<version>1.0.0</version>
26+
</dependency>
27+
```
28+
29+
To install manually, please check the [releases](https://github.com/millij/poi-object-mapper/releases) page for available versions and change log.
1730

1831
#### Dependencies
1932

@@ -23,6 +36,7 @@ The current implementation uses **POI version 3.17**.
2336
## Usage
2437

2538
### Spreadsheets (Excel)
39+
2640
Consider the below sample spreadsheet, where data of employees is present.
2741

2842
| Name | Age | Gender | Height (mts) | Address |
@@ -31,7 +45,9 @@ Consider the below sample spreadsheet, where data of employees is present.
3145
| John Doe | 45 | MALE | 2.1 | |
3246
| Guiliano Carlini | | MALE | 1.78 | Palo Alto, CA – 43234 |
3347

48+
3449
##### Mapping Rows to a Java Bean
50+
3551
Create a java bean and map its properties to the columns using the `@SheetColumn` annotation. The `@SheetColumn` annotation can be declared on the `Field`, as well as its `Accessor Methods`. Pick any one of them to configure the mapped `Column` as per convenience.
3652

3753
```java
@@ -60,7 +76,7 @@ Reading spreadsheet rows as objects ..
6076
...
6177
final File xlsxFile = new File("<path_to_file>");
6278
final XlsReader reader = new XlsReader();
63-
List<Employee> employees = reader.read(xlsxFile, Employee.class);
79+
List<Employee> employees = reader.read(Employee.class, xlsxFile);
6480
...
6581
```
6682

@@ -87,10 +103,12 @@ Reading spreadsheet rows as objects ..
87103

88104

89105

90-
## Known Issues
106+
## Issues
107+
108+
The known issues are already listed under [Issues Section](https://github.com/millij/poi-object-mapper/releases).
109+
110+
Please add there your bugs findings, feature requests, enhancements etc.
111+
112+
91113

92-
- Reading Large files is not suggested as stream reading is yet to be supported.
93-
- XLS file writing is not supported.
94-
- Mapping `Date` files through a `DateFormat` is not supported yet.
95-
- Reading `Formula` cells is not supported yet.
96114

build.gradle

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

1313
group = 'io.github.millij'
14-
version = '1.0.0-SNAPSHOT'
14+
version = '1.0.0'
1515

1616

1717
dependencies {
@@ -33,9 +33,9 @@ dependencies {
3333
// Test compile
3434
// ----------------------------------------------------------------------------------
3535

36-
testCompile group: "org.slf4j", name: "slf4j-log4j12", version: "1.7.12"
36+
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.12'
3737

38-
testCompile group: 'junit', name: 'junit', version: '4.+'
38+
testCompile group: 'junit', name: 'junit', version: '4.12'
3939

4040
}
4141

src/main/java/io/github/millij/poi/ss/reader/SpreadsheetReader.java

+139-12
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,157 @@
1616
public interface SpreadsheetReader {
1717

1818

19-
// Read with row eventHandler
20-
21-
<T> void read(Class<T> beanClz, File file, RowListener<T> eventHandler) throws SpreadsheetReadException;
22-
23-
<T> void read(Class<T> beanClz, InputStream is, RowListener<T> eventHandler) throws SpreadsheetReadException;
24-
25-
26-
<T> void read(Class<T> beanClz, File file, int sheetNo, RowListener<T> eventHandler)
27-
throws SpreadsheetReadException;
28-
29-
<T> void read(Class<T> beanClz, InputStream is, int sheetNo, RowListener<T> eventHandler)
19+
// Read with Custom RowListener
20+
21+
/**
22+
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
23+
* the available sheets of the file and creates the objects of the passed type.
24+
*
25+
* <p>
26+
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
27+
* Suited for reading Large files in restricted memory environments.
28+
* </p>
29+
*
30+
* @param <T> The Parameterized bean Class.
31+
* @param beanClz The Class type to deserialize the rows data
32+
* @param file {@link File} object of the spreadsheet file
33+
* @param listener Custom {@link RowListener} implementation for row data callbacks.
34+
*
35+
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
36+
* readable or row data to bean mapping failed.
37+
*/
38+
<T> void read(Class<T> beanClz, File file, RowListener<T> listener) throws SpreadsheetReadException;
39+
40+
41+
/**
42+
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
43+
* the available sheets of the file and creates the objects of the passed type.
44+
*
45+
* <p>
46+
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
47+
* Suited for reading Large files in restricted memory environments.
48+
* </p>
49+
*
50+
* @param <T> The Parameterized bean Class.
51+
* @param beanClz The Class type to deserialize the rows data
52+
* @param is {@link InputStream} of the spreadsheet file
53+
* @param listener Custom {@link RowListener} implementation for row data callbacks.
54+
*
55+
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
56+
* readable or row data to bean mapping failed.
57+
*/
58+
<T> void read(Class<T> beanClz, InputStream is, RowListener<T> listener) throws SpreadsheetReadException;
59+
60+
61+
/**
62+
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
63+
* (sheet numbers are indexed from 0) will be read.
64+
*
65+
* <p>
66+
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
67+
* Suited for reading Large files in restricted memory environments.
68+
* </p>
69+
*
70+
* @param <T> The Parameterized bean Class.
71+
* @param beanClz The Class type to deserialize the rows data
72+
* @param file {@link File} object of the spreadsheet file
73+
* @param sheetNo index of the Sheet to be read (index starts from 0)
74+
* @param listener Custom {@link RowListener} implementation for row data callbacks.
75+
*
76+
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
77+
* readable or row data to bean mapping failed.
78+
*/
79+
<T> void read(Class<T> beanClz, File file, int sheetNo, RowListener<T> listener) throws SpreadsheetReadException;
80+
81+
82+
/**
83+
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
84+
* (sheet numbers are indexed from 0) will be read.
85+
*
86+
* <p>
87+
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
88+
* Suited for reading Large files in restricted memory environments.
89+
* </p>
90+
*
91+
* @param <T> The Parameterized bean Class.
92+
* @param beanClz The Class type to deserialize the rows data
93+
* @param is {@link InputStream} of the spreadsheet file
94+
* @param sheetNo index of the Sheet to be read (index starts from 0)
95+
* @param listener Custom {@link RowListener} implementation for row data callbacks.
96+
*
97+
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
98+
* readable or row data to bean mapping failed.
99+
*/
100+
<T> void read(Class<T> beanClz, InputStream is, int sheetNo, RowListener<T> listener)
30101
throws SpreadsheetReadException;
31102

32103

33104

34-
// Read all
105+
// Read with default RowListener
35106

107+
/**
108+
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
109+
* the available sheets of the file and creates the objects of the passed type.
110+
*
111+
* @param <T> The Parameterized bean Class.
112+
* @param beanClz The Class type to deserialize the rows data
113+
* @param file {@link File} object of the spreadsheet file
114+
*
115+
* @return a {@link List} of objects of the parameterized type
116+
*
117+
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
118+
* readable or row data to bean mapping failed.
119+
*/
36120
<T> List<T> read(Class<T> beanClz, File file) throws SpreadsheetReadException;
37121

122+
123+
/**
124+
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
125+
* the available sheets of the file and creates the objects of the passed type.
126+
*
127+
* @param <T> The Parameterized bean Class.
128+
* @param beanClz The Class type to deserialize the rows data
129+
* @param is {@link InputStream} of the spreadsheet file
130+
*
131+
* @return a {@link List} of objects of the parameterized type
132+
*
133+
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
134+
* readable or row data to bean mapping failed.
135+
*/
38136
<T> List<T> read(Class<T> beanClz, InputStream is) throws SpreadsheetReadException;
39137

40138

139+
/**
140+
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
141+
* (sheet numbers are indexed from 0) will be read.
142+
*
143+
* @param <T> The Parameterized bean Class.
144+
* @param beanClz beanClz The Class type to deserialize the rows data
145+
* @param file file {@link File} object of the spreadsheet file
146+
* @param sheetNo index of the Sheet to be read (index starts from 0)
147+
*
148+
* @return a {@link List} of objects of the parameterized type
149+
*
150+
* @throws SpreadsheetReadException SpreadsheetReadException an exception is thrown in cases
151+
* where the file data is not readable or row data to bean mapping failed.
152+
*/
41153
<T> List<T> read(Class<T> beanClz, File file, int sheetNo) throws SpreadsheetReadException;
42154

155+
156+
/**
157+
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
158+
* (sheet numbers are indexed from 0) will be read.
159+
*
160+
* @param <T> The Parameterized bean Class.
161+
* @param beanClz beanClz The Class type to deserialize the rows data
162+
* @param is {@link InputStream} of the spreadsheet file
163+
* @param sheetNo index of the Sheet to be read (index starts from 0)
164+
*
165+
* @return a {@link List} of objects of the parameterized type
166+
*
167+
* @throws SpreadsheetReadException SpreadsheetReadException an exception is thrown in cases
168+
* where the file data is not readable or row data to bean mapping failed.
169+
*/
43170
<T> List<T> read(Class<T> beanClz, InputStream is, int sheetNo) throws SpreadsheetReadException;
44171

45172

0 commit comments

Comments
 (0)