I have 2D array data to add to the sheet. I have a script that will add columns in the Google app script. I used the setValue method for adding data in the Google sheet. I had data of length 784 to add to the sheet. After that, I'm trying to resize the column as per the text. When I have data of length 500 at that time autoSizeColumns method works fine but when I had data of length 784 at that time it's showing the error "Those columns are out of bounds". I don't know why this error is coming. The script working fine for printing data to the sheet but at resizeColumns it's giving an error.
Code for adding data into sheet.
const lastRow = SpreadsheetApp.getActiveSheet().getLastRow();
SpreadsheetApp.getActiveSheet().getRange(lastRow + 1, 1, arr.length, arr[0].length).setValues(arr);
SpreadsheetApp.getActiveSheet().autoResizeColumns(1, arr.length);
Can anyone Guide me on this?