Import data with the same Excel Header
Application Type
Traditional Web, Reactive

Hello everyone, I've been trying to import data from excel to Outsystems table. I have succeeded importing them using for each excel to record list, however, I want to match the header with some conditions. For example, in one excel I want the first row contents to be "Name", "Email", "Phone Number", and "Address". Otherwise, the excel cannot be imported and executed in Outsystems. Can anyone tell me how can I do it? (I'd also included the excel format which the user can download and upload)

P.S. supporting files such as .oml is much appreciated!

Thanks in advance~

Hi,

So basically you are trying to say that there will be 2 different excel. From first excel you will just fetch the name of columns and from second excel you will fetch the actual data. Is it the case ? What is the exact use case?

Regards

No, there will be only one excel and from the excel I am going to upload, I'll match them with an aggregate or table that I have made before. So basically, I am trying to upload an excel and match them with an aggregate.

Let's take an example, as you mentioned there are 4 columns in excel : "Name", "Email", "Phone Number", and "Address" 

So while uploading data from excel, you should map excel to aggregate directly or can create a structure of same datatype of mapping purpose only.

After that inside loop you can write the logic and other validations if required to check the data. Here you can also write the logic to change the mapping like Name column of excel can assign to "Address" column of aggregate.

Hi thanks for the response, I've done the mapping with a structure of the same datatype. But now I want to add some validations, for example if the excel format isn't the same with the structure it cannot be uploaded. Is there any way I can validate the excel data before it gets imported?

If format of excel is entirely different than structure entity than ExcelToRecordList method will fail and if any exception occur it will throw exception. But if any exception don't occur then you can check the size of RecordList. If size is zero means either blank excel is upload or format is not correct. So here you simply can show the message "upload valid excel in right format with data".

If RecordList size is more than 0, then you can execute the loop to check the validation for each field if required. Like in loop can check that entered email is a valid email address or not. Phone number is a valid phone number or not. If not valid then can skip that row to process or can skip entire excel as per your business logic.

Once you validate the excel for all inputs and its valid according to your business logic then at last you can process this data to insert in database.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.