Skip to content

nemanjakmno/vaadin-exceluploader-addon

 
 

Repository files navigation

Excel Uploader Add-on for Vaadin

Excel Uploader is a UI component add-on for Vaadin.

Excel Uploader Maven

<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>

FieldName Type Excel Uploader Example Code

FieldNameExcelUpload
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);

Annotation Type Excel Uploader Example Code

AnnotationExcelUpload
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);

AbstractExcelUploader Extension

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 { }

}

Building and running demo

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

Building from source

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+

License & Author

Add-on is distributed under Apache License 2.0. For license terms, see LICENSE.txt.

About

vaadin-exceluploader-addon-820

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%