Class library used: Microsoft.Office.Interop.
If the deployment to IIS prompts insufficient memory, please check the following two paths on the server to see if the "Desktop" directory exists, if not, create a new corresponding directory to solve the problem.
Path one:
C:\Windows\SysWOW64\config\systemprofile
Path two:
C:\Windows\System32\config\systemprofile

C# code snippet:

Original content, reproduced with attribution: Smart Tool Kit