Directory

← Back

Excel Uploader

Excel Uploader Add-on for Vaadin

Author

Contributors

Rating

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

  • allow extenssion *.xls or *.xlsx -> List

  • FieldName or Annotation Matching Excel Upload

  • AbstractExcelUploader Extension

// add option setFirstRow(2); // default : 0 setSheetAt(1); // default: 0 setSheetName("Sheet2"); // Target sheetAt or SheetName

Sample code

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

// add option
// excelUploader.setFirstRow(2);  // default : 0
// excelUploader.setSheetAt(1);  // default: 0
// excelUploader.setSheetName("Sheet2");  // Target sheetAt or SheetName

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

// add option
// excelUploader.setFirstRow(2);  // default : 0
// excelUploader.setSheetAt(1);  // default: 0
// excelUploader.setSheetName("Sheet2");  // Target sheetAt or SheetName

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

Links

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Changes in versioni 8.1.0 // add option excelUploader.setFirstRow(2); // default : 0 excelUploader.setSheetAt(1); // default: 0 excelUploader.setSheetName("Sheet2"); // Target sheetAt or SheetName

Released
2017-06-01
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 6.0+
Vaadin 7.0+
Vaadin 8.0+
Browser
Internet Explorer
Firefox
Opera
Safari
Google Chrome
Internet Explorer
Internet Explorer
Internet Explorer
Online