Skip to content

Commit

Permalink
update readme for 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ozlerhakan committed Jan 29, 2017
1 parent b8667d7 commit 6c41f50
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
= Poiji
:version: v1.0
:version: v1.1

image:https://travis-ci.org/ozlerhakan/poiji.svg?branch=master["Build Status", link="https://travis-ci.org/ozlerhakan/poiji"] image:https://api.codacy.com/project/badge/Grade/6587e90886184da29a1b7c5634695c9d["Codacy code quality", link="https://www.codacy.com/app/ozlerhakan/poiji?utm_source=github.com&utm_medium=referral&utm_content=ozlerhakan/poiji&utm_campaign=Badge_Grade"] image:https://img.shields.io/badge/license-MIT-blue.svg[]
image:https://travis-ci.org/ozlerhakan/poiji.svg?branch=master["Build Status", link="https://travis-ci.org/ozlerhakan/poiji"] image:https://api.codacy.com/project/badge/Grade/6587e90886184da29a1b7c5634695c9d["Codacy code quality", link="https://www.codacy.com/app/ozlerhakan/poiji?utm_source=github.com&utm_medium=referral&utm_content=ozlerhakan/poiji&utm_campaign=Badge_Grade"] image:https://coveralls.io/repos/github/ozlerhakan/poiji/badge.svg?branch=master["Coverage Status", link="https://coveralls.io/github/ozlerhakan/poiji?branch=master"] image:https://img.shields.io/badge/license-MIT-blue.svg[]

Poiji is a teeny Java framework that provides one way mapping from Excel sheets to Java classes. In a way it lets us convert each row of the specified excel data into Java objects. Poiji uses https://poi.apache.org/[Apache Poi] (the Java API for Microsoft Documents) under the hood to fulfill the mapping process.

== How it works

In your Java 8 Maven project, first add the following dependency into your pom:
In your Maven/Gradle project, first add the corresponding dependency:

.maven
[source,xml]
----
<dependency>
<groupId>com.github.ozlerhakan</groupId>
<artifactId>poiji</artifactId>
<version>1.0</version>
<version>1.1</version>
</dependency>
----

.gradle
[source,groovy]
----
dependencies {
compile 'com.github.ozlerhakan:poiji:1.1'
}
----

You can find the latest development version including javadoc and source files on https://oss.sonatype.org/content/groups/public/com/github/ozlerhakan/poiji/[Sonatypes OSS repository].

=== Example 1
Expand All @@ -28,22 +37,22 @@ Create your object model:
----
public class Employee {
@Index(column = 0, cell = 0) <1>
@ExcelCell(0) <1>
private long employeeId; <2>
@Index(column = 1, cell = 1)
@ExcelCell(1)
private String name;
@Index(column = 2, cell = 2)
@ExcelCell(2)
private String surname;
@Index(column = 3, cell = 3)
@ExcelCell(3)
private int age;
@Index(column = 4, cell = 4)
@ExcelCell(4)
private boolean single;
@Index(column = 5, cell = 5)
@ExcelCell(5)
private String birthday;
//no need getters/setters to map excel cells to fields
Expand All @@ -61,7 +70,7 @@ public class Employee {
}
}
----
<1> a field must be annotated with `@Index` along with its properties in order to get the value from the right coordinate in the target excel sheet.
<1> a field must be annotated with `@ExcelCell` along with its property in order to get the value from the right coordinate in the target excel sheet.
<2> an annotated field can be either protected, private or public modifier. The field may be either of `boolean`, `byte`, `short`, `int`, `long`, `char`, `float`, `double` or `String`.

This is the excel file (`employees.xlsx`) we want to map to a list of `Employee` instance:
Expand Down Expand Up @@ -112,24 +121,24 @@ Employee firstEmployee = employees.get(0);
// Employee{employeeId=123123, name='Sophie', surname='Derue', age=20, single=true, birthday='5/3/1997'}
----

== Example 2
=== Example 2

Your object model may be derived from a super class:

[source,java]
----
public abstract class Vehicle {
@Index(column = 0, cell = 0)
@ExcelCell(0)
protected String name;
@Index(column = 1, cell = 1)
@ExcelCell(1)
protected int year;
}
public class Car extends Vehicle {
@Index(column = 2, cell = 2)
@ExcelCell(2)
private int nOfSeats;
}
----
Expand Down

0 comments on commit 6c41f50

Please sign in to comment.