Search code examples
c#microsoft-graph-apiinteropoffice-interopword-interop

Is there an alternative to interop in microsoft graph?


I am currently using interop to update a word template automatically and then converting it to pdf.

I have come across many links which say that interop is not suggested by microsoft to automate any kind of office work as it may behave improperly.

I am facing the similar issues and that's why I am looking for better alternatives to update a docx. file automatically and then converting the same to pdf.

I searched the same in microsoft graph but only found that documents can be edited by user. Please help me out if I missed something.

Thanks in advance.


Solution

  • You need to use the Open XML SDK for dealing with Word documents (open XML documents only) on the fly. See Welcome to the Open XML SDK 2.5 for Office for more information.

    Automating Word from other applications may take more time and has the following restriction:

    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.