18
Views
10
Comments
[Advanced excel] Index and length must refer to a location within the string.

Hi, 


I'm trying to open an excel file worksheet, but the WorkBook_Select keeps crashing with this error: 



Does anyone knows how to solve this?

2019-01-07 16-04-16
Siya
 
MVP

Is this happening with all the Excel files or just a specific one? You may share the OML file so someone can take a look at it.

By the way, are you sure the exception is being thrown at WorkBook_Select or in another function? The error "Index and length must refer to a location within the string. Parameter name: length" usually occurs when a substring action is performed.

2022-09-26 08-44-58
Cristiana Esteves

To give you more context, I'm creating an excel file with the advanced excel, and then I'm importing that file. And in the flow I'm opening the workbook and then selecting the worksheet that was initially created, and I've already debugged it and it stops the flow on the WorkBook_Select.

I don't know If maybe it's a problem when creating the excel file, because if I open the excel, that was created by the advanced excel, and just save it one time, I'm not doing any changes literally just saving it, it doesn't throw any error

2019-01-07 16-04-16
Siya
 
MVP

Please check if the attached OML works in your environment. I have simulated your process at my end.

There are two methods in the server action: a) Create - Generates an Excel file. b) Read - Reads the Excel file from binary data.

In the UI, when you click on "Create & Read," it first creates the Excel file and then passes the binary data to the read function.

It works correctly in my environment.

ReadExcel.oml
2022-09-26 08-44-58
Cristiana Esteves

Yes, your OML works, and it does works correctly, mine keeps giving me the error.


My excel file is suppose to work as an template, and then the user is supposed to fill it with information, and it works, but If I try to import the excel file without opening it and saving it on excel, it gives that error, I'm really confused.

2019-01-07 16-04-16
Siya
 
MVP

Please check if the referenced modules are the same in both cases. Additionally, could you implement your logic in the version I shared and see if you can reproduce the error?

2022-09-26 08-44-58
Cristiana Esteves
2019-01-07 16-04-16
Siya
 
MVP

The shared OML seems to work at my end ( but I had to comment out the 'Merge Cell and write groups' functionality as I didn't know what to pass )

2022-09-26 08-44-58
Cristiana Esteves

Yeah, just realized it has something to do with the ConditionalFormatting, but I also don't know what wrong with it.

2019-01-07 16-04-16
Siya
 
MVP

You mean after commenting the 'Merge Cell and write groups'  it works at your end too ? If so do share the values you are passing to Features input parameter.

2022-09-26 08-44-58
Cristiana Esteves

Yes, I have a few WorkBook_ConditionalFormatting that are generating the error when importing, because if I disable the ConditionalFormatting it works just fine.


Added a ListAppend on CreateTemplate, and also the ConditionalFormatting.


https://personal-3qyu0gxm.outsystemscloud.com/Template/screen2
I leave here a link if someone wants to try it.

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