bingexcel User Guide
- 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:
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)