We are having issues in the action "WorkBook_AddSheet". This particular action is throwing an error "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index".
But this action does not throw an error when we copy the data from the existing to a new/empty excel file. This newly created excel file is an exact replica of the existing file which was originally throwing an error. But this particular action works fine with this newly created file.
Hi Nikhil
Are there any hidden sheets in the existing Excel file? Maybe that is causing the weirdness?
Hanno
Hi Hanno,
The first thing that we checked when we got an error was to check for hidden sheets. But there are no hidden sheets in the file.
One thing that we observed was the size difference between the error file and the file which was an exact replica of the error file(all sheets copied into a new file) ->
Error File: 113 kb
Copied File: 86 kb
So size difference can indicate there is something extra in the error file. But I do not see any difference in both the files
I don't think there is anything wrong with the document. I noticed that the description on the Worksheet paramater states "The worksheet object that you want to add. Set to nullbinary() if adding a new sheet by name".
That is actually incorrect, and it should be NullObject(). If I set the Worksheet parameter to ToObject(NullBinary()) it is not equal to NullObject() and the code tries to add a worksheet based off the Worksheet parameter, which contains a NullBinary(), i.e. this code "if (ssWorksheet != null)" evaluates to true.
Could you make sure that you are passing NullObject() to the Worksheet parameter when calling the Workbook_AddSheet action?
Let me know if this resolves your issue as well.
Sorry for the late reply. What I understand is that NullBinary()/NullObject() is to be assigned to the Worksheet Parameter when we are adding a new blank sheet.
But in our case, we are taking a sheet from one file and adding it to another file. So we cannot assign NullBinary()/NullObject() to the Worksheet Parameter. Instead we are adding the worksheet(object) that needs to be added in the Worksheet Parameter.