Excel Uploader is a UI component add-on for Vaadin.
<dependency>
<groupId>com.vaadin.addon</groupId>
<artifactId>excel-uploader</artifactId>
<version>${project.version}</version>
</dependency>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
public class User implements Serializable {
private Long id;
private String email;
private String name;
//....
final Grid<User> grid = new Grid<>();
grid.setSizeFull();
grid.addColumn(User::getId).setCaption("ID");
grid.addColumn(User::getName).setCaption("Name");
grid.addColumn(User::getEmail).setCaption("Email");
final ExcelUploader<User> excelUploader = new ExcelUploader<>(User.class);
excelUploader.addSucceededListener((event, items) -> {
if(items.size()>0) {
grid.setItems(items);
}
});
final Upload upload = new Upload();
upload.setButtonCaption("Upload");
upload.setReceiver(excelUploader);
upload.addSucceededListener(excelUploader);
public class UserEx implements Serializable {
@ExcelColumn("아이디")
private Long id;
@ExcelColumn("이메일")
private String email;
@ExcelColumn("이름")
private String name;
//....
final Grid<UserEx> grid = new Grid<>();
grid.setSizeFull();
grid.addColumn(UserEx::getId).setCaption("ID");
grid.addColumn(UserEx::getName).setCaption("Name");
grid.addColumn(UserEx::getEmail).setCaption("Email");
final ExcelUploader<UserEx> excelUploader = new ExcelUploader<>(UserEx.class);
excelUploader.addSucceededListener((event, items) -> {
if(items.size()>0) {
grid.setItems(items);
}
});
final Upload upload = new Upload();
upload.setButtonCaption("Upload");
upload.setReceiver(excelUploader);
upload.addSucceededListener(excelUploader);
public class ExcelUploader<T> extends AbstractExcelUploader {
@Override
protected Field findColumnField(Class targetClass, String columnName) throws NoSuchFieldException { }
@Override
protected void setColumnField(Object object, Field field, String columnValue) throws IllegalAccessException { }
}
Linux/Mac
sh mvnw clean install
sh mvnw -pl exceluploader-demo jetty:run
Windows
mvnw.cmd clean install
mvnw.cmd -pl exceluploader-demo jetty:run
Demo Server : http://127.0.0.1:8080
requires Java SE 1.7.0_79+
requires Maven 3.3.9+
requires Tomcat 8.0.36+
requires Eclipse Mars.2 4.5.2+
requires Vaadin Framework 7.7.3+