GithubHelp home page GithubHelp logo

malaiappan / excel-object-mapping Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pramoth/excel-object-mapping

0.0 2.0 0.0 230 KB

for map excel file to java object

License: Apache License 2.0

Java 100.00%

excel-object-mapping's Introduction

  • Clone this project to your computer
  • Build project by maven
$ mvn clean install -U
  • Add dependency to your project (pom.xml)
<dependency>
    <groupId>com.blogspot.na5cent</groupId>
    <artifactId>excel-object-mapping</artifactId>
    <version>1.0-SNAPSHORT</version>
</dependency>
  • Write code
List<YOUR_MODEL> objects = ExOM.mapFromExcel(EXCEL_FILE)
                .to(YOUR_MODEL.class)
                .map();

example

Model.java

public class Model {

    @Column(name = "first name") //must same excel header (first row)
    private String fistName;
    @Column(name = "last name")
    private String lastName;
    private Integer age; //use wrapper class only (*** not primitive type)
    @Column(name = "birth date", pattern = "dd/MM/yyyy")
    private Date birthdate;

    ...
    //getter and setter method
}

Test

File excelFile = new File(getClass().getResource("/excel.xlsx").getPath());
List<Model> items = ExOM.mapFromExcel(excelFile)
        .to(Model.class)
        .map();
        
for (Model item : items) {
    LOG.debug("first name --> {}", item.getFistName());
    LOG.debug("last name --> {}", item.getLastName());
    LOG.debug("age --> {}", item.getAge());
    LOG.debug("birth date --> {}", item.getBirthdate());
    LOG.debug("");
}  

excel-object-mapping's People

Contributors

jittagornp avatar

Watchers

James Cloos avatar Malaiappan Kannan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.