Implementing table insertion into Word using Office for JS (officejs)

159 Views Asked by At

Working on a project aiming to convert some C# based Word Add-in into JavaScript using officejs.

Quite surprised that after 5 years of development officejs API is not quite there in terms of coverage compared to C# API.

I am struggling how to translate the following C# Word API code into JavaScript based API. Seems that a lot of functionality is simply not there.

How can the following code be converted to Javascript to achieve the same level of end state functionality?

     MsWord.Table tblchart = rng.Tables.Add(rng, NumRows: 1, NumColumns: 1,
       AutoFitBehavior: MsWord.WdAutoFitBehavior.wdAutoFitFixed);
     tblchart.AllowPageBreaks = false;
     tblchart.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone;
     tblchart.Borders.InsideLineStyle = WdLineStyle.wdLineStyleNone;
     tblchart.Borders.Shadow = false;

     tblchart.TopPadding = tblchart.BottomPadding = tblchart.LeftPadding = 0f;
     tblchart.RightPadding = application.InchesToPoints(0.02f);
     tblchart.PreferredWidthType = MsWord.WdPreferredWidthType.wdPreferredWidthPoints;
     tblchart.set_Style(WordStyles.Table);
     tblchart.Range.set_Style(WordStyles.TableMaster);
     tblchart.Rows.WrapAroundText = System.Convert.ToInt32(false);
     tblchart.PreferredWidth = _Imagewidth;
     tblchart.Descr = _description;
     tblchart.Rows[1].AllowBreakAcrossPages = 0;
     tblchart.Rows[1].Range.set_Style(WordStyles.Figure);
     tblchart.Rows[1].Range.Text = "";
     tblchart.Rows.SetLeftIndent(LeftIndent: application.InchesToPoints(_leftIndent), RulerStyle: WdRulerStyle.wdAdjustNone);
0

There are 0 best solutions below