[Advanced Excel] Problem adding new sheets to a Workbook

Forge Component
(58)
Published on 2019-08-27 by Hanno
58 votes
Published on 2019-08-27 by Hanno

Hello Outsystems team

I'm trying to add a new sheet to an Excel file. As you can see in the image below, I started by creating an Excel Workbook. Then, I use a For Each to iterate a binary data list (my point here is to create a new sheet according to each element of that list). After that I use a Workbook_Open action where the Binary_Data input is the current element of that list, and then I use the Workbook_AddSheet action, and that's where the problem begins. My arguments here are the WorkBook that I created in the first action, some random name from a list (then I remove that name from the list in order not to create 2 sheets with the same name) and for the WorkSheet input I used the output of the Workbook_Open action, which contains the Binary data from the list that I want to add. I already debugged, and there's a problem right here, an error saying "Object reference not set to an instance of an object". I have no idea why, since I'm using two Objects as inputs in this action.

Does anyone understands why is this happening?

Alexandre

Here´s the image

Alexandre

Apologies for the delayed reply.

Attached is your .oml with slight modification. Note that you need to pass in the Worksheet object to the Workbook_Addsheet action, and not the excel file as a whole.

In the attached .oml I have built out the logic to correctly extract the worksheet that you want to add.

Please let me know if it solves your problem.

Hanno

Hanno wrote:

Alexandre

Apologies for the delayed reply.

Attached is your .oml with slight modification. Note that you need to pass in the Worksheet object to the Workbook_Addsheet action, and not the excel file as a whole.

In the attached .oml I have built out the logic to correctly extract the worksheet that you want to add.

Please let me know if it solves your problem.

Hanno

Hi Hanno

I changed my code according to yours, but I still got the same error, "Object reference not set to an instance of an object", which makes no sense to me, since I'm clearly using an object type as input... do you have any idea why is this happening?


Well, usually you would get that error if the object is not of the correct type.

I'll try and do a few tests to see why that error is occurring.

Hanno

Hanno wrote:

Well, usually you would get that error if the object is not of the correct type.

I'll try and do a few tests to see why that error is occurring.

Hanno

Hi, 


Here occur the same error and the Object is the output Select Worksheet.



Can help?


Cheers