Import data from CSV/Excel file

Hello Sir,
How to import data from CSV/Excel file ?
I have tried to import data using method given below

public class CustomerBrowse extends AbstractLookup {
    @Inject
    private FileUploadField uploadField;
    @Inject
    private FileUploadingAPI fileUploadingAPI;

    @Override
    public void init(Map<String, Object> params) {
        uploadField.addFileUploadSucceedListener(e -> {
            UUID fileId = uploadField.getFileId();
            File file = fileUploadingAPI.getFile(fileId);

            processFile(file);

            try {
                fileUploadingAPI.deleteFile(fileId);
            } catch (FileStorageException ex) {
                throw new RuntimeException(ex);
            }
        });
    }

    private void processFile(File file) {
        // import data
    }
}

but I am not getting any result after uploading Excel file in the application.

getting a warning: WARN c.h.c.web.sys.CubaApplicationServlet - Too long request processing [12526 ms]: ip=0:0:0:0:0:0:0:1, url=/app/UIDL/

Hi,

Take a look at this topic.

Regards,
Gleb

Hi,

Put a FileUploadField and a Button on a screen
The button click handler:

public void onBtnImportClick(Component source) {
    File importfile;
    if (fd != null) {
        importfile = fileUploadingAPI.getFile(upload.getFileId()) ;
        BackgroundWorkWindow.show(new BackgroundTask<Void, Void>(3600, this) {
            @Override
            public Void run(TaskLifeCycle<Void> taskLifeCycle) throws Exception {
                ProcessFile(importFile);
                importfile.delete();
                return null;
            }
            @Override
            public void canceled() {
                // Do something in UI thread if the task is canceled
                showNotification("Import is cancelled!", NotificationType.ERROR);
            }
            @Override
            public void done(Void result) {
                // Do something in UI thread when the task is done
                showNotification("Import completed!", NotificationType.HUMANIZED);
                close(CLOSE_ACTION_ID);
            }
        }, "File Import", "Please wait import is in progress....", true);
    }
}

Regards