471
Views
16
Comments
Solved
[Advanced Excel] Help with advance excel import
advanced-excel
Service icon
Forge asset by Carlos Freitas

Hi!

I need help for the following matter:

1 - I am importing an Excel file with multiple worksheets.

2 - I need to select only one of the worksheets.

3 - Create or Update in database.From the documentation of advance excel I followed this example (see attach) because it seemed it was the more correct approach, but its give the following error - "Object reference not set to an instance of an object." in WorkBook_AddSheet action.

4 - OutSystems 11 Web Traditional

Thanks for the help!

Best regards, 
Diogo






UserImage.jpg
Diogo Luciano
Solution

Hi everyone!

Thanks for your help @Sudip Pal and time! Sorry also for not responding earlier, but i was with a short time to deliver, but i want to share some important points that were raised in this discussion and also my solution for the problem.


  1. Updating the component - before anything else i updated the component Advance Excel and retested every hints the were given to me.
  2. Every possible solution presented here was ok for a simple excel with minimal configuration. And here is where i determined that was the problem. No matter what i did i couldn't make it work until the end because it gives some kind of error that could be the cell, the column, or some kind of filter. This file had 40+ columns and it is supposed to have 1000+ records so its a terrible time consuming process to figure out everything, specially if you don't have all the requirements defined.
  3. I didn't know because I never paid attention because I never need it until today or is something that OutSystems add it meanwhile, but the excel widget from OutSystems allows you to select the sheet, which means that you don't need advance excel to select a different sheet from the first as long as the file configuration is equal to what OutSystems needs to import to a list.

SOLUTION:

  1. I first imported the binary file to an entity so I can processed the file in the background using a LBPT.
  2. In the process I checked the first cell (I know which row and column to start) with the Read_Cell action from the Advanced Excel. This action retrieves the value of cell and then i assign to a structure that is the same type that I need to create or update my db.
  3. I cycle for every columns by incrementing the number columns with a local variable (i also know when is the last column.
  4. When the last column is read then I create or update the entire row with the the columns values in db and then I do the same for the other rows by incrementing the rows with a local variable.
  5. I know that the first column is a code and is mandatory, so when is empty i finish the importation.
  6. At the end I delete the binary data from the entity I created.

I hope this help for someone with similar problem. The read cell is very good for retrieving the values when the excel file is complex. From my testing, importing 2000+ data it takes me 1min to import in the background.


2023-09-06 07-26-35
Sudip Pal

Hi Diogo,

Please share the OML so that I can analyze your problem and will give you a perfect solution of your problem.

Thanks,

Sudip Pal

UserImage.jpg
Diogo Luciano

Hi Sudip!


Thanks for your response!


The oml contains business sentive information, so I can’t share it.


What I can do is try to replicate something similar, but it will take some time

2023-09-05 06-31-18
Pavan Rajapurkar

Hello Diogo,

I need more clarification in the requirement.. What exactly you want to do.

Do you want to create or update the data of a specific worksheet  to an entity?  

Because in the above flow you are copying the worksheet to new excel file and one more question after excel to record list what functionality you are performing?

Regards,

Pavan R

UserImage.jpg
Diogo Luciano

Hi Pavan!

The idea is for the client to upload an excel file with different worksheets, and I just want to select one worksheet and update the db with the respective information.

The way I described was my interpretation of what I needed to do from the documents of advanced excel, but if there is a better way I will follow it.

In resume, my difficulty is to select a worksheet from an excel with multiple worksheets.

Thanks in advance!

2023-09-06 07-26-35
Sudip Pal

Hey Diogo ,

I am attaching a small demo of the thing that you want to achieve.If your problem will still not resolved then please share your OML and describe your problem little bit more.

Thanks ,

Sudip Pal

Demo_Excel.oml
UserImage.jpg
Diogo Luciano

Hi again Sudip!


Sorry you posted this after I answered before.


I will check and come back with an reply.


Thank you!

Best regards!

2023-09-06 07-26-35
Sudip Pal

Hey Diogo,


Did you check my OML?Does it work? 


Thanks,

Sudip Pal

UserImage.jpg
Diogo Luciano

Hi Sudip!

Yes it works! And thanks in an advanced for your time!

But unfortunately it's the same as in my app (without the delete), and I don't know why it stops on the add sheet action.
Which means it must be a problem from the version of the component? Probably, I don't know.

So, I need an alternative option that gives me the same result. Any ideas?

Thanks!

2023-09-06 07-26-35
Sudip Pal

Hey Diogo,

I have an idea.You are getting problem for "Workbook_AddSheet".So don't use that action.

Let's say "Book.xlsx" is the Excel file which contains "Sheet1","Sheet2" and "Sheet3".Now open the work book and delete the first and last Excel and download the opened workbook.Now you will get the "Sheet2".

If possible then try this approach otherwise I think another approach.

Thanks,

Sudip Pal

2023-09-06 07-26-35
Sudip Pal

Hi Diogo,

I am giving you an alternative solution for the operation that you want to execute.I haven't used WorkBook_AddSheet action. Please have a look and let me know it works or not. If it does not work then we have to find another approach.

Thanks & Regards,

Sudip Pal 

Demo_Excel.oml
UserImage.jpg
Diogo Luciano

Hi Sudip!
I tried this approach, but I am having a problem with one of the indexes. For example, I have 6 sheets. Delete sheet 1 - ok, delete sheet 2 - pass, delete sheet 3 - ok, delete sheet 4 - ok, delete sheet 5 - error.
Is there a way to retrieve how many indexes the workbook has?

Thank you!

2023-09-06 07-26-35
Sudip Pal

Hi Diogo,

Please download my last OML and use that approach.I have already trouble shoot the issue that you are facing now.


Thanks ,

Sudip Pal

UserImage.jpg
Diogo Luciano

Hi Sudip!
The last oil that you post it it was the same as the one before. Did you upload the wrong one by mistake?

1 - https://www.outsystems.com/forums/discussion/90519/help-with-advance-excel-import/#Post386248

2 - https://www.outsystems.com/forums/discussion/90519/help-with-advance-excel-import/#Post386263

2023-09-06 07-26-35
Sudip Pal

Hi Diogo,

You are right.It is by mistake.Let me send you again.Give me some time.

Thanks,

Sudip Pal

2023-09-06 07-26-35
Sudip Pal

Hey Diogo,

Sorry for my mistake.I am sending you the latest OML.

Thanks,

Sudip Pal

Demo_Excel_New.oml
UserImage.jpg
Diogo Luciano
Solution

Hi everyone!

Thanks for your help @Sudip Pal and time! Sorry also for not responding earlier, but i was with a short time to deliver, but i want to share some important points that were raised in this discussion and also my solution for the problem.


  1. Updating the component - before anything else i updated the component Advance Excel and retested every hints the were given to me.
  2. Every possible solution presented here was ok for a simple excel with minimal configuration. And here is where i determined that was the problem. No matter what i did i couldn't make it work until the end because it gives some kind of error that could be the cell, the column, or some kind of filter. This file had 40+ columns and it is supposed to have 1000+ records so its a terrible time consuming process to figure out everything, specially if you don't have all the requirements defined.
  3. I didn't know because I never paid attention because I never need it until today or is something that OutSystems add it meanwhile, but the excel widget from OutSystems allows you to select the sheet, which means that you don't need advance excel to select a different sheet from the first as long as the file configuration is equal to what OutSystems needs to import to a list.

SOLUTION:

  1. I first imported the binary file to an entity so I can processed the file in the background using a LBPT.
  2. In the process I checked the first cell (I know which row and column to start) with the Read_Cell action from the Advanced Excel. This action retrieves the value of cell and then i assign to a structure that is the same type that I need to create or update my db.
  3. I cycle for every columns by incrementing the number columns with a local variable (i also know when is the last column.
  4. When the last column is read then I create or update the entire row with the the columns values in db and then I do the same for the other rows by incrementing the rows with a local variable.
  5. I know that the first column is a code and is mandatory, so when is empty i finish the importation.
  6. At the end I delete the binary data from the entity I created.

I hope this help for someone with similar problem. The read cell is very good for retrieving the values when the excel file is complex. From my testing, importing 2000+ data it takes me 1min to import in the background.


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