Easy access to Excel read and write operations-POI-based framework bingexcel (1)

Source: Internet
Author: User

bingexcel User Guide
    1. Using Maven for project development
      The current project's MAVEN repository is on GitHub, with a browse address of Https://github.com/bingyulei007/mvn-repo/tree/master/repository/com/bing/excel, When you use it, you just add a remote repository:
    <repositories>        <repository>            <id>bingyulei-mvn-repo</id>            <url>https:/ /raw.github.com/bingyulei007/mvn-repo/master/repository</url>        </repository>    </ Repositories>

Then add a reference to the jar package to make it easy to read and write Excel.

    <dependency>        <groupId>com.bing</groupId>        <artifactid>excel</artifactid >        <version>1.2-SNAPSHOT</version>     </dependency>

2. Simple Read instance
You can download the person table from here, the data

Then you need to create a Java entity object that corresponds to the table content:

  1.  Public classPerson {@CellConfig (index= 1)    Private intAge ; //@CellConfig (index = 0,readrequired=true)@CellConfig (index = 0)    PrivateString name; @CellConfig (Index= 3)    PrivateDouble Salary;  PublicString GetName () {returnname; }     Public voidsetName (String name) { This. Name =name; }     Public intGetage () {returnAge ; }     PublicDouble getsalary () {returnsalary; }     PublicString toString () {returnMoreobjects.tostringhelper ( This. GetClass ()). Omitnullvalues (). Add ("Name", name). Add ("Age", age). Add ("Salary", salary). ToString (); }}

    The @CellConfig is a key configuration that corresponds to the mapping relationship. Then you can start reading and writing. Here is an introduction to the general pattern of small amounts of data:

    New File ("Person.xls");     = Bingexcelbuilder.tobuilder (). Builder ();     Try {        sheetvo<Person> vo = Bing.readfile (f, person. ) Class, 1);        System.out.println (Vo.getsheetindex ());//print the corresponding sheet order        System.out.println (Vo.getsheetname ());// The name of the corresponding sheet worksheet        System.out.println (Vo.getobjectlist ());//    data Object catch  (Exception e) {        e.printstacktrace ();    }
more content can be concerned: Project address Https://git.oschina.net/bingyulei007/bingExcel, can also go to the project page message. Provide valuable suggestions for improvement

Easy access to Excel read and write operations-POI-based framework bingexcel (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.