Is there any component to allow end users edit "Content Controls" in a C# Windows Forms desktop application?
I have many complicated Word Documents which are ready for edit and can't create all of them on runtime.
I searched stackoverflow but didn't find anything
Thanks
CodePudding user response:
you need to use .NET Word component which is easily installed in VS using
https://www.nuget.org/packages/FreeSpire.Doc/ then you need to include following namespaces
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
after this you can easily create a new word document , add sections and / or paraghraphs
Document document = new Document();
Section section = document.AddSection();
Paragraph paragraph = section.AddParagraph();
Hope this is what you are looking for
CodePudding user response:
You may consider using the Open XML SDK if you deal only with open XML documents. See How to insert text into a content control with the Open XML SDK for more information.
A big plus is that SDK doesn't require Word installed on the system. Also such code can be used on the server-side without any issues. Be aware, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.