Skip to content

Commit

Permalink
Merge branch 'v3.x.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
millij committed Dec 19, 2023
2 parents 674c22e + b5abd1f commit 87cfd8d
Show file tree
Hide file tree
Showing 32 changed files with 1,739 additions and 890 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: java
jdk:
- openjdk8
- openjdk11

env:
- CODECOV_TOKEN="6f3f7d4d-3eab-4605-b631-294c4fb7a58f"
Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ This library is available in [Maven Central](https://mvnrepository.com/artifact/
<dependency>
<groupId>io.github.millij</groupId>
<artifactId>poi-object-mapper</artifactId>
<version>2.1.0</version>
<version>3.0.0</version>
</dependency>
```

To install manually, please check the [releases](https://github.com/millij/poi-object-mapper/releases) page for available versions and change log.

#### Dependencies

The current implementation uses **POI version 4.1.2**.
The current implementation uses **POI version 5.2.5**.


## Usage
Expand All @@ -48,7 +48,7 @@ Consider the below sample spreadsheet, where data of employees is present.

##### Mapping Rows to a Java Bean

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.
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.

```java
@Sheet
Expand All @@ -68,34 +68,38 @@ public class Employee {

##### Reading Rows as Java Objects

Once a mapped Java Bean is ready, use a `Reader` to read the file rows as objects. Use `XlsReader` for `.xls` files and `XlsxReader` for `.xlsx` files.
Once a mapped Java Bean is ready, use a `Reader` to read the file rows as objects.

Use `XlsReader` for `.xls` files and `XlsxReader` for `.xlsx` files.

Reading spreadsheet rows as objects ..

```java
...
final File xlsxFile = new File("<path_to_file>");
final XlsReader reader = new XlsReader();
List<Employee> employees = reader.read(Employee.class, xlsxFile);
final List<Employee> employees = reader.read(Employee.class, xlsxFile);
...
```

##### Writing a collection of objects to file

*Currently writing to `.xlsx` files only is supported*
Similar to `Reader`, the mapped Java Beans can be written to files.

Use `XlsWriter` for `.xls` files and `XlsxWriter` for `.xlsx` files.

```java
...
// Employees
List<Employee> employees = new ArrayList<Employee>();
final List<Employee> employees = new ArrayList<>();
employees.add(new Employee("1", "foo", 12, "MALE", 1.68));
employees.add(new Employee("2", "bar", null, "MALE", 1.68));
employees.add(new Employee("3", "foo bar", null, null, null));

// Writer
SpreadsheetWriter writer = new SpreadsheetWriter("<output_file_path>");
final SpreadsheetWriter writer = new XlsxWriter();
writer.addSheet(Employee.class, employees);
writer.write();
writer.write("<output_file_path>");
...
```

Expand All @@ -107,7 +111,7 @@ Reading spreadsheet rows as objects ..

The known issues are already listed under [Issues Section](https://github.com/millij/poi-object-mapper/issues).

Please add there your bugs findings, feature requests, enhancements etc.
Please add there your bugs findings, feature requests, enhancements etc.



Expand Down
24 changes: 10 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ repositories {
mavenCentral()
}


sourceCompatibility = 1.11
targetCompatibility = 1.11

group = 'io.github.millij'
version = '2.1.0'
version = '3.0.0'


dependencies {
Expand All @@ -20,23 +24,20 @@ dependencies {
// ----------------------------------------------------------------------------------

// Slf4j
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.3'

// Apache Commons
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'

// Apache POI
compile group: 'org.apache.poi', name: 'poi', version: '4.1.2'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
implementation group: 'org.apache.poi', name: 'poi', version: '5.2.5'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.2.5'


// Test compile
// ----------------------------------------------------------------------------------

testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.12'

testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'

}

Expand All @@ -51,11 +52,6 @@ test {
// Java
// ----------------------------------------------------------------------------

tasks.withType(JavaCompile) {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sun Dec 10 18:59:49 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
Loading

0 comments on commit 87cfd8d

Please sign in to comment.