Share via

ExcelScript issue .addRow() returns error: The argument is invalid or missing or has an incorrect format.

Anonymous
2023-04-25T08:45:53+00:00

We made the bellow script to handle some company sheets and it worked fine for 2 months , before 3 weeks I saw it was throwing error.
last Loop ( aRowIndexes.forEach) , executes once for table1, adds the row, throws the error and stops.

error message : Table addRow: The argument is invalid or missing or has an incorrect format.

function main(workbook: ExcelScript.Workbook ){ // Get the table by its name.const table = workbook.getTable("TableMaster");const aTargetTables = [// workbook.getTable("TableTest")workbook.getTable("Table1"),workbook.getTable("Table2")workbook.getTable("Table3"),workbook.getTable("Table4"),workbook.getTable("Table5"),workbook.getTable("Table6"),workbook.getTable("Table7"),workbook.getTable("Table8"),workbook.getTable("Table9"),workbook.getTable("Table10"),workbook.getTable("Table11"),workbook.getTable("Table12")]const sourceRange = table.getRangeBetweenHeaderAndTotal();const dataRows: (number | string | boolean)[][] = table.getRangeBetweenHeaderAndTotal().getValues();

let projectWBSes = aTargetTables[0].getColumn(1).getRangeBetweenHeaderAndTotal().getValues().map(x => x[0]);

    let newProjectWBSes = table.getColumn(1).getRangeBetweenHeaderAndTotal().getValues().map(x => x[0]); let aRowIndexes: (number)[] = [];let aColumnIndexes: (number)[] = [];

newProjectWBSes.forEach((x, i) => {if(projectWBSes.indexOf(x)===-1){console.log("bike",x, projectWBSes.indexOf(x))aRowIndexes.push(i)}})if (aRowIndexes.length>0){aTargetTables.forEach( y => {aRowIndexes.forEach( x => {

dataRows[x][1] = '=IF(ISBLANK(VLOOKUP([@Project],TableMaster,2,FALSE))," ",VLOOKUP([@Project],TableMaster,2,FALSE))'dataRows[x][2] = '=IF(ISBLANK(VLOOKUP([@Project],TableMaster,3,FALSE))," ",VLOOKUP([@Project],TableMaster,3,FALSE))'dataRows[x][3] = '=IF(ISBLANK(VLOOKUP([@Project],TableMaster,4,FALSE))," ",VLOOKUP([@Project],TableMaster,4,FALSE))'dataRows[x][4] = '=IF(ISBLANK(VLOOKUP([@Project],TableMaster,5,FALSE))," ",VLOOKUP([@Project],TableMaster,5,FALSE))'dataRows[x][5] = "=SUM([@[Avlastimidou, Maria]:[add members at the Master sheet and save]])"console.log("x", x)console.log("datarows", dataRows)console.log("datarow", dataRows[x])

y.addRow(x, dataRows[x]); <==== Error is here})})       console.log("dataEntered" ) }console.log("finished" )}

x is an integer
dataRows[x] is an array of strings https://prnt.sc/G0kUgBv-Cciv https://prnt.sc/G0kUgBv-CcivnumberColums for each table (TableMaster and Table1,2,3 etc) are the same ( 44 )
addRow( ) documentation ExcelScript.Table interface - Office Scripts | Microsoft Learn

May you please help us ? :)

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2023-04-25T09:55:43+00:00

Our category focus on excel function, we’d suggest you go to Microsoft Power Automate Community - Power Platform Community to post a new thread, which is the specific channel to handle Office script issue.

Members and engineers over there are proficient in the knowledge of handling such situations. They will focus on the specific situation on your side and share suggestions for you. They also have enough environment to help you test it. We're sure that you will get a more detailed and professional answer there.

Thank you for your understanding.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-04-26T08:57:56+00:00

    Was this answer helpful?

    0 comments No comments