0

I don't want a header on the table. For that, I passed the false in the tables.add method and also used the showHeaders:false for not visible the headers in the table. The table headers are not visible but there is one single row displayed at the top of the table. I had attached the screenshot for that. My code is below.

How can I remove that line?

Table image

  await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getActiveWorksheet();
    let expensesTable = sheet.tables.add("A1:D1", false);
    expensesTable.name = "ExpensesTable";
    expensesTable.showHeaders = false;

    expensesTable.rows.add(null, [
      ["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"]
    ]);
    if (Office.context.requirements.isSetSupported("ExcelApi", "1.2")) {
      sheet.getUsedRange().format.autofitColumns();
      sheet.getUsedRange().format.autofitRows();
    }

    sheet.activate();

    await context.sync();
  });
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Shiv Yadav
  • 467
  • 2
  • 11

1 Answers1

1

You may find a similar post describing the same behavior, see showHeaders=false results in unexpected Table Range using Javascript.

The showHeaders property specifies if the header row is visible. This value can be set to show or remove the header row. If the row is still visible I'd suggest posting this as a bug to the OfficeJS repo. At least the documentation must be changed if a bug is not confirmed.

Note, you can also post or vote for an existing feature request on Tech Community where they are considered when the Office dev team goes through the planning process.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45