0

I'm trying to create an ```Office add-in`` for Excel but encounter the following problem. This occurred after updating de server.

Setup:

  • Excel API 1.1
  • Windows Server 2019 Standard (17763.2565)
  • Office 2016 (16.0.52)

Code:

export async function run() {
  try {
    Excel.run(function (context) {
      //var sheet = context.workbook.worksheets.getItem("Sample");
      var sheet = context.workbook.worksheets.getActiveWorksheet();
      var expensesTable = sheet.tables.add("A1:D1", true /*hasHeaders*/);
      expensesTable.name = "ExpensesTable";
  
      expensesTable.getHeaderRowRange().values = [["Date", "Merchant", "Category", "Amount"]];
  
      expensesTable.rows.add(null /*add rows to the end of the table*/, [
        ["1/1/2017", "The Phone Company", "Communications", "$120"],
        ["1/2/2017", "Northwind Electric Cars", "Transportation", "$142"],
        ["1/5/2017", "Best For You Organics Company", "Groceries", "$27"],
        ["1/10/2017", "Coho Vineyard", "Restaurant", "$33"],
        ["1/11/2017", "Bellows College", "Education", "$350"],
        ["1/15/2017", "Trey Research", "Other", "$135"],
        ["1/15/2017", "Best For You Organics Company", "Groceries", "$97"]
      ]);
  
      sheet.activate();
  
      return context.sync();
    })
    .catch(function (error) {
      console.log("Error: " + error);
      if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
      }
    });
  } catch (error) {
    console.error(error);
  }
}

results in:

Error: InvalidArgument: The argument is invalid or missing or has an incorrect format.
Debug info: {"code":"InvalidArgument","message":"The argument is invalid or missing or has an incorrect format.","errorLocation":"TableRowCollection.add"}

enter image description here

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
roapp
  • 530
  • 6
  • 17
  • I don't see anything wrong with the parameters passed to `expensesTable.rows.add`. Can you reproduce this error in [Script Lab](https://learn.microsoft.com/office/dev/add-ins/overview/explore-with-script-lab)? – Rick Kirkham Feb 11 '22 at 22:10
  • 1
    @RickKirkham Thanks for your response. I tried but Script Lab doesn't support IE 11 anymore. So I can't check. If I try the code on another platform it will execute without errors. – roapp Feb 14 '22 at 06:53
  • If it only happens with IE, then it might be bug. I suggest you raise this as an issue on the [office-js](https://github.com/OfficeDev/office-js/issues) repo. – Rick Kirkham Feb 14 '22 at 17:44
  • Thats a pretty basic function that almost every single one of my sub routines will call once my ad and is ready for production.. scary to see this is a bug, please post answer ir update OP w issue link so I can follow! – FreeSoftwareServers Feb 14 '22 at 22:53
  • 1
    @FreeSoftwareServers https://github.com/OfficeDev/office-js/issues/2429 – roapp Feb 15 '22 at 07:20

1 Answers1

0

Adding an extra argument as first parameter worked for me

expensesTable.rows.add(null,null, [["1/1/2017", "The Phone Company", "Communications", "$120"]])
roapp
  • 530
  • 6
  • 17