I'm working on migrating our addins from ArcMap to ArcGIS Pro 3.0.3. Currently I'm trying to replace EPPPlus with ClosedXML. it's not working as part of the addin. I can get it to run fine in a standalone app, so believe it may be related to dependencies somehow. Has anyone else tried this? I'm using a pro window, but moved the test code up the button handling before the window appears and it still fails.
It fails during the saveAs, and a file is created, but it is corrupt and non-salvageable.
Solved! Go to Solution.
I actually tried to create an Add-in sample that writes an XML file using ClosedXML and was not able to get it to work properly. After some testing it turns out that one of the dependencies of ClosedXML is DocumentFormat.OpenXML which is already included with ArcGIS Pro in the ArcGIS Pro bin folder. I was unable to find a matching release of ClosedXML, so i wrote my sample using DocumentFormat.OpenXML instead. The trick here is that you have to reference the DocumentFormat.OpenXML.dll file in the ArcGIS Pro bin folder and to NOT include the DocumentFormat.OpenXML NuGet. Using the NuGet might lead to another version mismatch. Also when including the OpenXML reference make sure that no specific version is listed and the copy local setting is false.
I attached my sample project.
I actually tried to create an Add-in sample that writes an XML file using ClosedXML and was not able to get it to work properly. After some testing it turns out that one of the dependencies of ClosedXML is DocumentFormat.OpenXML which is already included with ArcGIS Pro in the ArcGIS Pro bin folder. I was unable to find a matching release of ClosedXML, so i wrote my sample using DocumentFormat.OpenXML instead. The trick here is that you have to reference the DocumentFormat.OpenXML.dll file in the ArcGIS Pro bin folder and to NOT include the DocumentFormat.OpenXML NuGet. Using the NuGet might lead to another version mismatch. Also when including the OpenXML reference make sure that no specific version is listed and the copy local setting is false.
I attached my sample project.
I had switched to OpenXml yesterday and was wondering about if there was a version conflict. For the most part, I can get it to work using Nuget, but I'll switch to the version included with ArcGIS Pro.
I wonder if I compile ClosedXml (the version using the OpenXml version included with Pro), using the OpenXml from the ArcGis folder, if it will work? OpenXml takes a lot more work to get all of the styles working the way I need to. I'll try out a couple of options today. Thank you for the sample project.
Hello Wolf,
I have the same problem and your solution is just an explanation, why it doesn't work -> very old DocumentFormat.OpenXML.dll from 2015, shipped by ArcGIS Pro 3.1 (in my case).
I would love to use a modern version of the lib (2.20.0) in my addins, or even use ClosedXML (https://github.com/ClosedXML/ClosedXML) but it's not possible.
Are there any plans at ESRI to switch the OpenXML-SDK lib (https://github.com/dotnet/Open-XML-SDK) to a recent Version in, for example, 3.2 or 3.3?
Can I get any informations about this topic at the european dev summit next month?
Just for information, I forked ClosedXml and OpenXmlSDK, removed all non necessary projects (tests, examples, etc), configured them to just build .NET 6 (fixed some errors with no longer used hasing-methods) and changed the assembly names (added a prefix). Then I used the new OpenXmlSDK assembly for my ClosedXml fork, included the new ddls in my pro addin module and it just worked.
In theory that should work but you have to make sure not to specify a specific version of the OpenXML dll since an upgrade of ArcGIS Pro could ship with a newer release of OpenXML.
The issue I had was methods used in the new OpenXML were not available in the one supplied by ArcGIS Pro.
I'll continue using the version in ArcGIS Pro for now, but may still run into breaking changes as the version in ArcGIS Pro is quite old and many things have been changed in the later versions.
Based on our testing, I would assume that using EPPlus would fail as well since it also uses OpenXml as a dependency. It's good information to know if you're trying to output excel reports. We used EPPlus in our ArcMap addin and I was just testing open source when migrating to ArcGIS Pro.
Thanks again for your help.