Skip to content

Map your excel with Java entity add simple annotations

Notifications You must be signed in to change notification settings

CriptoCosmo/excel-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExcelUtil

Add these snippets in your pom.xml

...
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
...
<dependency>
    <groupId>com.github.CriptoCosmo</groupId>
    <artifactId>excel-util</artifactId>
    <version>master</version>
</dependency>
...

Example - Excel File

Example Excel File

Example - ModelEntity

@ExcelEntity
public class ExcelRow {
	
	private static final String PATTERN = "dd MMMM yyyy";
	private static final String LOCALE = "it";
	
	@ExcelField private String nome ;
	@ExcelField private String cognome ;
	@ExcelField private Double classe ;
	
	// CUSTOM PATTERN AND LOCALE 
	@ExcelField(value=PATTERN,locale=LOCALE) 
	private Date data ;
    
	// DEFAULT DATE 
	@ExcelField 
	private Date data2 ;

}

Example - BasicUsage

public static void main(String[] args) throws Exception {
	
    String path = "C:\Users\Cosmo\Desktop\sample.xlsx" ;
	
	ExcelReader<ExcelRow> excelReader = new ExcelReaderImpl<ExcelRow>(ExcelRow.class,path);
	
	for (ExcelRow excelRow : excelReader.readRows()) {
		System.out.println(excelRow);
	}
}

Result

ExcelRow [nome=Mario, cognome=Arbola, classe=5.0, data=Fri Jul 19 00:00:00 CEST 1996, data2=Fri Jan 19 00:00:00 CET 1900]

ExcelRow [nome=Gabriele, cognome=Cipolloni, classe=5.0, data=Sat Nov 11 00:00:00 CET 1995, data2=Fri Jan 19 00:00:00 CET 1900]

About

Map your excel with Java entity add simple annotations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages