Row number must be between 1 and 1048576 Error

Hi, UI Path Community. I download Excel file from SAP and try to work with it using UI Path and closed XML. I have this code inside my Invoke Code activity:
“var wb = new XLWorkbook(loc);
var ws = wb.Worksheet(1);
ws.Range(“A3:B5”).Style.Fill.BackgroundColor = XLColor.FromArgb(255,165,0);
However, I get this error: “RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.IndexOutOfRangeException: Row number must be between 1 and 1048576”
An interesting fact is that if I manually make any changes to my Excel document (deleting a row, cell, column / adding new cell / changing data in some random cell) I do not get above error.
So, this error occurs only in original excel file. Making any change to it helps to solve it; however, those changes need to be done manually (client’s machine does not have MS Office). How can this problem be solved?

Which option do you select while downloading from SaP.
Spreadsheet, XML, CSV, etc.
After download what is actual extension do you get.

1 Like

Thanks, your questions helped me to solve the issue. I was downloading .XLS file, but was renaming that file to .XLSX. Removing this unnecessary action helped to solve the issue.

Thanks, your questions and other comment helped to solve the issue. SAP was exporting a .XLS format file, but I was renaming that file format to “.XLSX”. causing an issue in reading data from that file.