IRM-Protected Excel File: ClosedXML Error and Interop.Excel Deployment Issue

87 Views Asked by At

I'm currently grappling with a challenge involving an Excel file protected using Information Rights Management (IRM). In our project, we're using ClosedXML to read and generate another Excel file. However, ClosedXML encounters an error when attempting to read the IRM-protected file.

In an attempt to find an alternative solution, I explored using Microsoft.Office.Interop.Excel. Surprisingly, it successfully reads the IRM-protected Excel file in Visual Studio 2022's debug mode. However, when trying to deploy the solution on IIS and calling the endpoint with Insomnia, the process doesn't initiate. There is no response. It's worth mentioning that I resolved an initial error when calling the endpoint, "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (0x80070005 ( E_ACCESSDENIED))," by adding the user "IIS_IUSRS" in Computer Services -> My Computer -> Properties -> COM security -> edit default.

Here's a brief summary of the issues:

 ClosedXML: Generates an error when attempting to read an IRM-protected Excel file. ClosedXML don 't support IRM.
 Microsoft.Office.Interop.Excel: Successfully reads the file in Visual Studio 2022's debug mode. However, the deployment on IIS causes the process not to start when calling the endpoint with Insomnia. I added code to generate a .txt log in the Windows temporary folder, but it simply doesn't initiate.

I'm seeking advice and alternative approaches. Has anyone encountered a similar situation, especially concerning successful debugging in Visual Studio but facing issues when deploying with IIS? Are there alternative libraries or methods for effectively manipulating IRM-protected Excel files?

0

There are 0 best solutions below