Java library for mapping Excel sheets to POJO
Java
Switch branches/tags
Latest commit 5fba9c5 Jul 25, 2014 @takezoe Merge pull request #3 from ssogabe/ignoreNotFoundSheet
ignoreSheetNotFound not work correctly
Permalink
Failed to load latest commit information.
src ignoreSheetNotFound not work correctly Jul 24, 2014
.classpath Initial Commit. Dec 30, 2013
.gitignore Ignore target directory. Dec 30, 2013
.project Initial Commit. Dec 30, 2013
LICENSE Initial commit Dec 30, 2013
README.md fixed typo Jul 14, 2014
command.bat Initial Commit. Dec 30, 2013
eclipse.bat Initial Commit. Dec 30, 2013
excel.png Initial Commit. Dec 30, 2013
pom.xml Update version to 1.2.5. Mar 2, 2014

README.md

XLSBeans

XLSBeans is a Java library for mapping Excel sheets to POJO.

Setup

To use XLSBeans, add the following dependency to your pom.xml:

<repositories>
  <repository>
    <id>amateras</id>
    <name>Project Amateras Maven2 Repository</name>
    <url>http://amateras.sourceforge.jp/mvn/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>jp.sf.amateras.xlsbeans</groupId>
    <artifactId>xlsbeans</artifactId>
    <version>1.2.5</version>
  </dependency>
</dependencies>

Getting Started

For example, here is one Excel sheet.

Sample Excel

Map this Excel sheet to POJO using @HorizontalRecords and @LabelledCell.

@Sheet(name="Users")
public class UserList {

  @LabelledCell(label="Title", type=LabelledCellType.Right)
  public String title;

  @HorizontalRecords(tableLabel="User list", recordClass=User.class)
  public List<User> users;

}

And the following is the record class. Properties of the record class is mapped to columns by @Column.

public class User {

  @Column(columnName="ID")
  public int id;

  @Column(columnName="Name")
  public String name;

  @Column(columnName="Gender", merged=true)
  public String gender;

}

You can get the mapped POJO using XLSBeans#load() like following:

UserList userList = (UserList)new XLSBeans().load(
  new FileInputStream("example.xls"), UserList.class);

Documentation

See more details in http://amateras.sourceforge.jp/site/xlsbeans/howtouse.html