diff --git a/README.adoc b/README.adoc index e7a804c..5216bf2 100644 --- a/README.adoc +++ b/README.adoc @@ -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] ---- com.github.ozlerhakan poiji - 1.0 + 1.1 ---- +.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 @@ -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 @@ -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: @@ -112,7 +121,7 @@ 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: @@ -120,16 +129,16 @@ Your object model may be derived from a super class: ---- 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; } ----