Common_Coder
Common_Coder

Reputation: 151

is it possible to set column width and Background color for table headers

I am trying to create a table in word document using Office Js.

I need to set the width for the two columns at 20% resp. 80%.

The table header should be formatted with a background color.

enter image description here

I tried using this code

var Table = body.insertTable(2, array.length, Word.InsertLocation.start, [array]); 
Table.styleBuiltIn = Word.Style.GridTable1Light_Accent1

I can't find the correct properties.

The entire function

function createTable() {    
  Word.run(function (context) {
    var body = context.document.body;
    var Table = body.insertTable(2, array.length, Word.InsertLocation.start, [array]);    
    return context.sync();
  })
  .catch(errorHandler);
}

Upvotes: 2

Views: 226

Answers (0)

Related Questions