Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

asp.net - Add Footnotes with a Word Extension

I want to create an extension that runs on Mac and Windows. The extension should insert footnotes at the position of the cursor. As far as I know, Office.js doesn't have a suitable interface for this. I found this in the .NET API Browser (https://docs.microsoft.com/de-de/dotnet/api/microsoft.office.interop.word.footnote?view=word-pia):

public Microsoft.Office.Interop.Word.Footnote Add (Microsoft.Office.Interop.Word.Range Range, ref object Reference, ref object Text);

But the Net Framework cannot be used on Mac. Do you have another solution to my problem?

question from:https://stackoverflow.com/questions/65834260/add-footnotes-with-a-word-extension

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Office.js can be used to insert footnotes into a Word document. Currently, there is no Footnotes API that would make this easy, but we can still use the Ooxml APIs to insert footnotes into the document.

Here is an example gist that uses Ooxml to replace the current selection in the document with a sample text and sample footnote. I tried my best to separate out the relevant parts of the Ooxml in case you want to modify the code to incorporate multiple texts and footnotes:

Insert footnotes using Ooxml

You can use ScriptLab to import the above gist and play around with the sample.

An Office Add-in solution using Office.js can be used on Mac, along with on Windows, and on Web.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...